<template>
  <div style="height: 100%; width: 100%; position: relative">
      <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=67 :canDrag=false>
          <template v-slot:fix>
              <div style="height:63px;border:1px solid #CCC">
                  <div style="float: left; width: 100%">
                      <table>
                          <tr>
                              <td width="50px">仪器</td>
                              <td>
                                  <rm-ddl-instrument @change="labinstrumentchange" width="200px" v-model="instrId" defaultflag="1" prgno="LIS511" :clearable="false"></rm-ddl-instrument>
                              </td>
                              <td width="50px">批号</td>
                              <td>
                                  <el-input v-model="batchno" style="width: 120px" @keyup.enter.native="initialList"></el-input>
                              </td>
                              <td width="50px">水平</td>
                              <td>
                                  <rm-ddl-common datatype="seccode" kindno="QCLEVEL" dataname="水平" v-model="qclevel" width="120px" @change="initialList"></rm-ddl-common>
                              </td>
                              <td width="100px">实际批号</td>
                              <td>
                                  <el-input v-model="batchno1" style="width: 120px" @keyup.enter.native="initialList()"></el-input>
                              </td>
                              <td>
                                  <el-checkbox style="padding: 0px 10px" v-model="checkreportflag" true-label="1" false-label="0" @change="initialList">报告依据</el-checkbox>
                              </td>
                              <!-- <td>
                                  <el-checkbox style="padding: 0px 10px" v-model="showallbatch" true-label="1" false-label="0">显示所有批号</el-checkbox>
                              </td> -->
                              <td>
                                  <el-radio-group v-model="showallbatch" style="padding: 0px 10px" size="mini" @change="initialList()">
                                      <el-radio-button label="0">在用</el-radio-button>
                                      <el-radio-button label="1">全部</el-radio-button>
                                  </el-radio-group>
                              </td>
                              <td></td>
                          </tr>
                      </table>
                  </div>
                  <!-- 操作按钮 -->
                  <table width="100%">
                      <tr>
                          <td align="right" width="100%">
                              <el-button icon="el-icon-search" @click="initialList()" v-has="'PINQUERY'">查询(F8)</el-button>

                              <el-button icon="el-icon-plus" @click="masterAdd()" v-has="'PADD'">新增(F2)</el-button>

                              <el-button icon="el-icon-edit-outline" @click="masterUpdate()" v-has="'PMODIFY'">修改(M)</el-button>

                              <el-button icon="el-icon-delete-solid" @click="masterDelete()" v-has="'PDELETE'">删除(F3)</el-button>

                              <el-button icon="el-icon-circle-plus" @click="qcCopy_click()">质控品复制(C)</el-button>

                              <el-button icon="el-icon-news" @click="targetSet_click()">靶值设定(T)</el-button>
                              <el-button icon="el-icon-tickets" @click="batchnoChange_click()">更换批号(B)</el-button>
                              <el-button icon="el-icon-close" @click="BtnExc">退出(E)</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
          </template>
          <!-- 左边list列表 -->
          <rm-layout-left :splitwidth=5 :fixsize=500 :minfixsize=300 :maxfixsize=800>
              <template v-slot:fix>
                  <vxe-table show-overflow ref="xTable1" height="auto" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData1" border size="mini" :row-class-name="rowClassName" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @current-change="masterRowChangedEvent">
                      <vxe-table-column type="index" title="NO." width="30" sortable></vxe-table-column>
                      <vxe-table-column field="qcname" title="质控品名称" width="130" sortable header-align="center"></vxe-table-column>
                      <vxe-table-column field="batchno" title="批号" width="80" sortable header-align="center"></vxe-table-column>
                      <vxe-table-column field="qclevel" title="水平" width="45" sortable align="center"></vxe-table-column>
                      <vxe-table-column field="startdt" title="质控品启用日期" width="120" :formatter="['toDateString', 'yyyy-MM-dd']" sortable align="center"></vxe-table-column>
                      <vxe-table-column field="expriedt" title="有效期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" sortable align="center"></vxe-table-column>
                      <vxe-table-column field="stopdt" title="停用日期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" align="center" sortable></vxe-table-column>
                      <vxe-table-column field="cp_stopuser" title="停用人" width="60" align="center" sortable></vxe-table-column>
                      <vxe-table-column field="inputdt" title="录入日期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" align="center" sortable></vxe-table-column>
                      <vxe-table-column field="cp_inputuser" title="录入人" width="60" align="center" sortable></vxe-table-column>
                      <vxe-table-column field="batchno1" title="实际批号" width="100" align="center" sortable></vxe-table-column>
                      <vxe-table-column field="manufacturercode" title="生产厂家" width="150" header-align="center" sortable></vxe-table-column>
                      <vxe-table-column field="vendoncode" title="供应商" width="150" header-align="center" sortable></vxe-table-column>
                      <vxe-table-column field="checkreportflag" title="报告依据" width="60" align="center" :formatter="formatterCheckreportflag" sortable></vxe-table-column>
                      <vxe-table-column field="reagentvendor" title="试剂厂商" width="200" align="center" sortable></vxe-table-column>
                      <vxe-table-column field="calibratevendor" title="校准品厂商" width="200" header-align="center" sortable></vxe-table-column>
                      <vxe-table-column field="ccl_batchno" title="临检中心质控批号" width="200" header-align="center" sortable></vxe-table-column>
                      <vxe-table-column field="qcid" title="质控品ID" width="80" align="center" sortable></vxe-table-column>
                  </vxe-table>
              </template>
              <!-- 右边数据展现tab -->
              <el-tabs style="height: 100%" type="border-card">
                  <el-tab-pane label="质控品项目">
                      <div :style="{ width: '100%', height: ItemJudgeShow ? '60%' : '100%' }">
                          <vxe-table show-overflow ref="xTable2" :height="ItemJudgeShow ? '100%' : 'auto'" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData2" border size="mini" :row-class-name="rowClassName" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @current-change="0" @cell-click="qcTableClick">
                              <vxe-table-column type="index" title="NO." width="30" sortable></vxe-table-column>
                              <vxe-table-column field="seq" title="序号" width="40" sortable header-align="center" align="center"></vxe-table-column>
                              <vxe-table-column field="rpt_itemname" title="报告项目" width="180" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="tagvalue" title="靶值" width="60" header-align="center" align="right" sortable></vxe-table-column>
                              <vxe-table-column field="SD" title="SD" width="60" header-align="center" align="right" sortable></vxe-table-column>
                              <vxe-table-column field="CV" title="CV" width="60" header-align="center" align="right" sortable></vxe-table-column>
                              <vxe-table-column field="stopdt" title="停用日期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="stopuser" title="停用人" width="60" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="inputdt" title="录入日期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="inputuser" title="录入人" width="60" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="qcruletype" title="规则类别" width="70" :formatter="['formatSelect', westgardOption]" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="checkreportflag" title="报告依据" width="60" :formatter="['formatSelect', dgList]" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="reagentmnfcturname" title="试剂厂商" width="150" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="reagentbatchno" title="试剂批号" width="120" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="calibratemnfcturname" title="校准品厂商" width="120" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="calibrateno" title="校准品批号" width="120" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="reagentvendorname" title="试剂供应商" width="120" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="calibratevendorname" title="校准品供应商" width="120" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="qcmethod" title="方法学" width="150" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="maxcv" title="允许最大CV%" width="120" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="refer_tagvalue" title="厂商靶值参考" width="130" header-align="center" sortable></vxe-table-column>
                              <vxe-table-column field="startdt" title="质控品启用日期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="expriedt" title="有效期" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="qcid" title="质控品ID" width="80" header-align="center" align="center" sortable></vxe-table-column>
                              <vxe-table-column field="rpt_itemcode" title="项目代码" width="100" header-align="center" sortable></vxe-table-column>
                          </vxe-table>
                      </div>
                      <div v-show="ItemJudgeShow" style="height: 39%; width: 100%; margin-top: 5px">
                          <vxe-table show-overflow ref="xTableJudge" height="auto" width="100%" :cell-class-name="rowClassNameItem" :data.sync="tableDataJudge" :key="tableDataJudgeKey" border size="mini" :keyboard-config="keyConfig" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="0">
                              <vxe-table-column field="seq" title="序号" width="60" sortable header-align="center" align="center"></vxe-table-column>
                              <vxe-table-column field="result_str" title="结果" width="150" header-align="center"></vxe-table-column>
                              <vxe-table-column field="controlstatus" title="在控标志" width="100" header-align="center" :formatter="formatterControlStatus"></vxe-table-column>
                              <vxe-table-column field="qcid" title="质控项目ID" width="100" header-align="center"></vxe-table-column>
                          </vxe-table>
                      </div>
                  </el-tab-pane>
                  <el-tab-pane label="质控品">
                      <div style="height: 50%">
                          <table style="width: 100%" class="showDataTable">
                              <tr>
                                  <td style="width: 20%">质控品名称：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.qcname }}</td>
                                  <td style="width: 20%">质控品ID：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.qcid }}</td>
                              </tr>
                              <tr>
                                  <td style="width: 20%">批号：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.batchno }}</td>

                                  <td style="width: 20%">水平：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.qclevel }}</td>
                              </tr>
                              <tr>
                                  <td style="width20%">质控品启用日期：</td>
                                  <td style="width: 30%">{{ this.com_startdt }}</td>
                                  <td style="width: 20%">停用日期/操作者：</td>
                                  <td style="width: 30%">{{ this.com_stopdt }} /{{ this.qcsDisplay.cp_stopuser }}</td>
                              </tr>
                              <tr>
                                  <td style="width: 20%">有效期：</td>
                                  <td style="width: 30%">{{ this.com_expriedt }}</td>
                                  <td style="width: 20%">录入日期/操作者：</td>
                                  <td style="width: 30%">{{ this.com_inputdt }}/{{ this.qcsDisplay.cp_inputuser }}</td>
                              </tr>

                              <tr>
                                  <td style="width: 20%">实际批号：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.batchno1 }}</td>
                                  <td style="width: 20%">生产厂家：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.manufacturercode }}</td>
                              </tr>
                              <tr>
                                  <td style="width: 20%">供应商：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.vendoncode }}</td>
                                  <td style="width: 20%">试剂厂商：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.reagentvendorname }}</td>
                              </tr>
                              <tr>
                                  <td style="width: 20%">临检中心质控批号：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.ccl_batchno }}</td>

                                  <td style="width: 20%">校准品厂商：</td>
                                  <td style="width: 30%">{{ this.qcsDisplay.calibratevendor }}</td>
                              </tr>
                              <tr>
                                  <td style="width: 20%">报告依据：</td>
                                  <td>
                                      <el-checkbox v-model="this.com_checkreportflagDisplay"></el-checkbox>
                                  </td>
                              </tr>
                          </table>
                      </div>
                  </el-tab-pane>
              </el-tabs>
          </rm-layout-left>
      </rm-layout-top>

      <!-- 以下为新增和修改弹窗    -->
      <el-dialog width="1000px" top="10px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="质控品新增/维护" :visible.sync="dialogTableVisible">
          <div style="height: 35%; font-size: 12px">
              <el-form ref="qcsForm2" :model="qcsForm" @submit.native.prevent label-width="auto" :rules="rules">
                  <table class="showDataTable" style="text-align: right; font-size: 12px; width: 100%">
                      <tr>
                          <td style="width: 80px">质控品ID：</td>
                          <td>
                              <el-input style="width: 100%" v-model="qcsForm.qcid" disabled="disabled"></el-input>
                          </td>
                          <td style="width: 70px; color: blue">启用日期：</td>
                          <td style="width: 220px">
                              <el-date-picker v-model="qcsForm.startdt" type="date" placeholder="选择日期" style="width: 128px"></el-date-picker>

                              <el-button @click="startdtcopy_click()">应用到明细</el-button>
                          </td>
                          <td style="width: 100px">停用日期：</td>
                          <td style="width: 220px">
                              <el-date-picker v-model="qcsForm.stopdt" type="date" placeholder="选择日期" style="width: 128px"></el-date-picker>
                              <el-button @click="stopdtcopy_click()">应用到明细</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td style="width: 100px; color: blue">仪器：</td>
                          <td>
                              <rm-ddl-instrument :disabled="true" width="100%" v-model="instrId" defaultflag="1" prgno="LIS511" :clearable="false"></rm-ddl-instrument>
                          </td>
                          <td style="width: 70px; color: blue">有效期：</td>
                          <td>
                              <el-date-picker v-model="qcsForm.expriedt" type="date" placeholder="选择日期" style="width: 128px"></el-date-picker>

                              <el-button @click="expriedtcopy_click()">应用到明细</el-button>
                          </td>
                          <td style="width: 60px">停用人：</td>
                          <td>
                              <el-input style="width: 100%" v-model="qcsForm.cp_stopuser" disabled="disabled"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td style="width: 100px; color: blue">质控品名称：</td>
                          <td>
                              <!-- <el-form-item prop="qcname" size="mini" :inline-message="true" :show-message="false"> -->
                              <el-input style="width: 100%" v-model="qcsForm.qcname"></el-input>
                              <!-- </el-form-item> -->
                          </td>
                          <td style="width: 70px">生产厂家：</td>
                          <td>
                              <!-- <el-input style="width: 100%" v-model="qcsForm.manufacturercode"></el-input> -->
                              <rm-ddl-common datatype="invvendorna" dataname="供应商" v-model="qcsForm.manufacturercode" width="100%" key="4"></rm-ddl-common>
                          </td>

                          <td style="width: 60px">录入日期：</td>
                          <td>
                              <el-date-picker v-model="qcsForm.inputdt" type="date" placeholder="选择日期" style="width: 100%" disabled="disabled"></el-date-picker>
                          </td>
                      </tr>
                      <tr>
                          <td style="width: 100px; color: blue">批号：</td>
                          <td>
                              <el-input style="width: 100%" v-model="qcsForm.batchno"></el-input>
                          </td>
                          <td style="width: 70px">供应商：</td>
                          <td>
                              <rm-ddl-common datatype="invvendorna" dataname="供应商" v-model="qcsForm.vendoncode" width="100%" key="2"></rm-ddl-common>
                              <!-- <el-input style="width: 100%" v-model="qcsForm.vendoncode"></el-input> -->
                          </td>
                          <td style="width: 60px">录入人：</td>
                          <td>
                              <el-input style="width: 100%" v-model="qcsForm.cp_inputuser" disabled="disabled"></el-input>
                          </td>
                      </tr>
                      <tr>
                          <td style="width: 100px; color: blue">水平：</td>
                          <td>
                              <!-- 这个组件有问题， 新增时偶尔会不能绑定到 qcsForm.qclevel ，保存时报错提示没有水平 -->
                              <!-- <rm-ddl-common datatype="seccode" kindno="QCLEVEL" dataname="水平" v-model="qcsForm.qclevel" width="100%" ref="qclevelpop"></rm-ddl-common> -->
                              <el-select v-model="qcsForm.qclevel" style="width: 100%">
                                  <el-option v-for="qclevel in qclevelList" :key="qclevel.value" :value="qclevel.value" :label="qclevel.label"> </el-option>
                              </el-select>
                          </td>
                          <td style="width: 70px">试剂厂商：</td>
                          <td>
                              <rm-ddl-common datatype="invvendorna" dataname="供应商" v-model="qcsForm.reagentvendorcode" width="100%" key="3"></rm-ddl-common>
                          </td>

                          <td style="width: 60px">校准品厂商：</td>
                          <td>
                              <rm-ddl-common datatype="invvendorna" dataname="供应商" v-model="qcsForm.calibratevendor" width="100%" key="4"></rm-ddl-common>
                              <!-- <el-input style="width: 100%" v-model="qcsForm.calibratevendor"></el-input> -->
                          </td>
                      </tr>
                      <tr>
                          <td style="width: 100px"></td>
                          <td>
                              <!-- <el-checkbox v-model="this.com_checkreportflagDisplay">报告依据</el-checkbox>   -->
                              <el-checkbox v-model="qcsForm.checkreportflag" true-label="1" false-label="0">可作为报告依据</el-checkbox>
                          </td>
                          <td style="width: 70px">实际批号：</td>
                          <td>
                              <el-input style="width: 100%" v-model="qcsForm.batchno1"></el-input>
                          </td>
                          <td style="width: 60px">临检中心批号：</td>
                          <td>
                              <el-input style="width: 100%" v-model="qcsForm.ccl_batchno"></el-input>
                          </td>
                      </tr>
                  </table>
              </el-form>
          </div>
          <div style="width: 100%">
              <table style="width: 100%">
                  <tr>
                      <td>
                          <div :style="{ height: '280px', width: ItemJudgeShowDialog ? '710px' : '950px' }">
                              <vxe-table show-overflow ref="xTable3" height="auto" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData3" border size="mini" :row-class-name="rowClassName" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @cell-click="qcTableClickDialog">
                                  <vxe-table-column field="seq" title="序号" width="60" sortable align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="rpt_itemname" key="rpt_itemname" title="报告项目" width="200px" header-align="center" :edit-render="{ name: 'input', autoselect: true }">
                                      <!-- 改为弹窗选 取消ddl -->
                                      <template v-slot:edit="{ row }">
                                          <el-input v-model="row.rpt_itemcode" @dblclick.native="detailInsertItem(row)"></el-input>
                                          <!-- detailInsertItem -->
                                          <!-- (dialogTestVisible = true), (temprptitem = row)   -->
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="startdt" title="靶值启用日期" width="130" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center">
                                      <template v-slot="{ row }">
                                          <el-date-picker v-model="row.startdt" type="date" placeholder="选择日期" style="width: 100%"></el-date-picker>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="expriedt" title="有效期" width="130" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center">
                                      <template v-slot="{ row }">
                                          <el-date-picker v-model="row.expriedt" type="date" placeholder="选择日期" style="width: 100%"></el-date-picker>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="checkreportflag" title="报告依据" width="60" align="center">
                                      <template v-slot="{ row }">
                                          <el-checkbox v-model="row.checkreportflag" true-label="1" false-label="0" v-if="row.checkreportflag == '1'" checked="checked" :key="1"></el-checkbox>
                                          <el-checkbox v-model="row.checkreportflag" true-label="1" false-label="0" v-else :key="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="stopdt" title="停用日期" width="130" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center">
                                      <template v-slot="{ row }">
                                          <el-date-picker v-model="row.stopdt" type="date" placeholder="选择日期" style="width: 100%"></el-date-picker>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="stopuser" title="停用人" width="60" header-align="center" align="center"></vxe-table-column>
                                  <vxe-table-column field="qcruletype" title="规则类别" width="70" :formatter="['formatSelect', westgardOption]" align="center"></vxe-table-column>
                                  <vxe-table-column field="reagentmnfcturname" title="试剂厂商" width="150" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="reagentbatchno" title="试剂批号" width="100" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="calibratemnfcturname" title="校准品厂商" width="150" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="calibrateno" title="校准品批号" width="100" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="reagentvendorname" title="试剂供应商" width="150" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="calibratevendorname" title="校准品供应商" width="150" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="qcmethod" title="方法学" width="150" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="refer_tagvalue" title="厂商靶值参考" width="150" header-align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="qcid" title="质控品ID" width="80" header-align="center" align="center"></vxe-table-column>
                                  <vxe-table-column field="inputdt" title="录入日期" width="120" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center"></vxe-table-column>
                                  <vxe-table-column field="inputuser" title="录入人" width="60" header-align="center" align="center"></vxe-table-column>
                                  <vxe-table-column type="index" title="NO." width="50"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </td>
                      <td v-show="ItemJudgeShowDialog">
                          <div style="width: 239px; height: 280px">
                              <vxe-table show-overflow ref="xTableJudge2" height="auto" width="100%" :data.sync="tableDataJudgeDialog" :cell-class-name="rowClassNameItem" border size="mini" :keyboard-config="keyConfig" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="0">
                                  <vxe-table-column field="seq" title="序号" width="60" sortable header-align="center" align="center" :edit-render="{ name: 'input', autoselect: true }"></vxe-table-column>
                                  <vxe-table-column field="result_str" title="结果" width="90" header-align="center"></vxe-table-column>
                                  <vxe-table-column field="controlstatus" title="在控标志" width="120" header-align="center" :formatter="['formatSelect', controlstatusList]" :edit-render="{ name: 'select', options: controlstatusList }"></vxe-table-column>
                                  <!-- <vxe-table-column field="qcid" title="质控项目ID" width="100" header-align="center"></vxe-table-column> -->
                                  <template v-slot:fix>
                                      <div style="font-size: 12px; padding: 5px; background-color: #fff; text-align: center">
                                          <div class="bottom-table-button">
                                              <el-button @click="ItemJudgeCopy()">复制</el-button>
                                              <el-button :disabled="!itemcopyflag" @click="ItemJudgePaste()">粘贴</el-button>
                                              <el-button @click="ItemJudgeSave()">保存</el-button>
                                              <!-- <el-button style="background-color: #e6e6e6; color: black;" @click="ItemJudgeAdd()">新增</el-button>
                                              <el-button style="background-color: #e6e6e6; color: black;" @click="ItemJudgeDel()">删除</el-button> -->
                                          </div>
                                      </div>
                                  </template>
                              </vxe-table>
                          </div>
                      </td>
                  </tr>
              </table>
          </div>

          <div align="right" style="margin: 10px 2px 0px 0px">
              <el-button @click="detailAddSelect()" icon="el-icon-circle-plus">新增明细</el-button>
              <el-button @click="detailAdd()" icon="el-icon-plus">插入明细</el-button>
              <el-button @click="detailDelete_clicked()" icon="el-icon-minus">删除明细</el-button>
              <el-button @click="save()" icon="el-icon-success">确 定</el-button>
              <el-button @click="cancel()" icon="el-icon-close">取 消</el-button>
          </div>

          <el-dialog width="1000px" top="10px" v-el-drag-dialog :append-to-body="true" destroy-on-close :close-on-click-modal="false" title="仪器质控项目" :visible.sync="detailAddDialogVisible">
              <rm-pop-common datatype="qcinstritem" dataname="仪器质控项目" :instrid="parseInt(instrId)" :multiple="true" @cancel="detailAddDialogVisible = false" @change="detailAddItems" ref="qcinstritem1"> </rm-pop-common>
          </el-dialog>
          <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="仪器质控项目" :visible.sync="dialogTestVisible">
              <rm-pop-common datatype="qcinstritem" dataname="仪器质控项目" :instrid="instrId" @cancel="dialogTestVisible = false" @change="addrptitem" ref="qcinstritem2"> </rm-pop-common>
          </el-dialog>
      </el-dialog>

      <!-- 删除确认 弹窗 -->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="提示" :visible.sync="deleteDialogVisible" width="30%">
          <div class="el-message-box__status el-icon-warning"></div>
          <div class="el-message-box__message" style="padding-top: 24px">
              <p>
                  确定要删除质控品
                  <b style="color: red">{{ this.qcsDisplay.qcname }}</b>吗?
              </p>
          </div>

          <span slot="footer" class="dialog-footer">
              <el-button @click="masterDeleteOK()">确 定</el-button>
              <el-button @click="masterDeleteCancll()">取 消</el-button>
          </span>
      </el-dialog>
      <!-- 复制数据   初始弹窗-->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="质控数据复制选择" :visible.sync="bSelectCopyMode" width="270px" height="40px;">
          <div style="width:250px;padding-top:10px;height:40px;display:flex">
              <div style="flex:1">
                  <el-button @click="CopyByAnother()">复制至其他仪器</el-button>
              </div>
              <div style="flex:1">
                  <el-button @click="CopyInstrSelfAdd()">本仪器内新增复制</el-button>
              </div>
          </div>
      </el-dialog>
      <!-- 复制数据 弹窗1 复制到其他仪器里 -->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="质控数据复制    请选择目标仪器" :visible.sync="qcCopyDialogVisible" width="500px">
          <div style="width: 100%">
              <table>
                  <tr>
                      <td>快速检索</td>
                      <td style="width: 320px; text-align: left">
                          <el-input style="width: 200px" v-model="txtsearch" placeholder="仪器名称 或 仪器代码" @keyup.enter.native="qcCopySearch_change" clearable></el-input>
                          <el-button icon="el-icon-search" @click="qcCopySearch_change()">查询</el-button>
                      </td>
                  </tr>
                  <tr>
                      <td></td>
                      <td>
                          <el-checkbox v-model="com_qcCopyOverride" size="mini">覆盖原有质控品数据</el-checkbox>
                          <el-checkbox v-model="qcCopyItemvalue" size="mini" true-label="1" false-label="0">复制靶值</el-checkbox>
                      </td>
                  </tr>
              </table>
          </div>
          <div style="padding: 5px 0"></div>
          <div style="width: 100%">
              <vxe-table show-overflow ref="xTable4" height="400px" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData4" border size="mini" row-id="instrid" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @current-change="0">
                  <vxe-table-column type="selection" width="40" align="center"></vxe-table-column>
                  <vxe-table-column field="instrid" title="仪器ID" width="0" v-if="false" header-align="center"></vxe-table-column>
                  <vxe-table-column field="instrname" title="仪器名称" width="180" header-align="center"></vxe-table-column>
                  <vxe-table-column field="instrno" title="仪器代号" width="100" header-align="center"></vxe-table-column>
                  <vxe-table-column field="labgroupname" title="工作组" width="100" header-align="center"></vxe-table-column>
              </vxe-table>
          </div>
          <div style="padding: 5px 0"></div>
          <div style="width: 100%" align="right">
              <span slot="footer" class="dialog-footer">
                  <el-button @click="qcCopyOK_click()">复 制</el-button>
                  <el-button @click="qcCopyCancel_click()">取 消</el-button>
              </span>
          </div>
      </el-dialog>
      <!-- 复制数据 弹窗2 复制当前选中 -->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="请输入新增质控品的信息" :visible.sync="bCopySelfAdd" width="950px" height="100px">
          <table class="showDataTable" style="text-align: right; font-size: 12px; width: 100%">
              <tr>
                  <td style="width: 80px; color: blue">质控品名称：</td>
                  <td>
                      <el-input style="width: 100%" v-model="copyForm.qcname"></el-input>
                  </td>
                  <td style="width: 6px; color: blue">批号：</td>
                  <td>
                      <el-input style="width: 100%" v-model="copyForm.batchno"></el-input>
                  </td>
                  <td style="width: 6px; color: blue">水平：</td>
                  <td>
                      <!-- 这个组件有问题， 新增时偶尔会不能绑定到 qcsForm.qclevel ，保存时报错提示没有水平 -->
                      <el-select v-model="copyForm.qclevel" style="width: 100%">
                          <el-option v-for="qclevel in qclevelList" :key="qclevel.value" :value="qclevel.value" :label="qclevel.label"> </el-option>
                      </el-select>
                  </td>
              </tr>
              <tr>
                  <td style="width: 80px; color: blue">启用日期：</td>
                  <td>
                      <el-date-picker v-model="copyForm.startdt" type="date" placeholder="选择日期" style="width: 57%"></el-date-picker>
                      <el-checkbox style="padding-left:10px" v-model="copyForm.cpstart" true-label="1" false-label="0">应用到项目</el-checkbox>
                  </td>
                  <!-- <td style="width: 6px; color: blue">停用日期：</td>
                  <td>
                      <el-date-picker v-model="copyForm.stopdt" type="date" placeholder="选择日期" style="width: 57%"></el-date-picker>
                      <el-checkbox style="padding-left:10px"  v-model="copyForm.cpstop" true-label="1" false-label="0">应用到项目</el-checkbox>
                  </td> -->
                  <td style="width: 6px; color: blue">有效期：</td>
                  <td>
                      <el-date-picker v-model="copyForm.expriedt" type="date" placeholder="选择日期" style="width: 57%"></el-date-picker>
                      <el-checkbox style="padding-left:10px" v-model="copyForm.cpexprie" true-label="1" false-label="0">应用到项目</el-checkbox>
                  </td>

              </tr>
          </table>
          <div align="right" style="margin: 10px 2px 0px 0px">

              <el-button @click="qcCopySelf_click()" icon="el-icon-success">确 定</el-button>
              <el-button @click="bCopySelfAdd=false" icon="el-icon-close">取 消</el-button>
          </div>

      </el-dialog>
      <!-- 更换批号 -->
      <el-dialog width="750px" top="10px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="更换批号  （原有数据按新的批号，批量生成新的质控品、质控项目、质控靶值数据）" :visible.sync="batchnoChangeDialogVisible">
          <div style="height: 35%; font-size: 12px">
              <el-form ref="qcsForm5" :model="qcsForm" @submit.native.prevent label-width="auto">
                  <table class="showDataTable" style="text-align: right; font-size: 12px; width: 100%">
                      <tr>
                          <td style="width: 100px">质控品：</td>
                          <td style="width: 150px">{{ this.qcsDisplay.qcname }}</td>
                          <td style="width: 100px">仪器：</td>
                          <td style="width: 150px">{{ this.instrName }}</td>
                          <td style="width: 100px">水平：</td>
                          <td style="width: 150px">{{ this.qcsDisplay.qclevel }}</td>
                      </tr>

                      <tr>
                          <td style="width: 100px">原批号：</td>
                          <td style="width: 100px">{{ this.qcsDisplay.batchno }}</td>
                          <td style="width: 100px">原质控品启用日期：</td>
                          <td style="width: 150px">{{ this.com_startdt }}</td>
                          <td style="width: 100px">原有效期：</td>
                          <td style="width: 150px">{{ this.com_expriedt }}</td>
                      </tr>
                      <tr>
                          <td style="width: 100px; color: blue">新批号：</td>
                          <td style="width: 150px">
                              <el-input style="width: 100%" v-model="qcsForm.batchno"></el-input>
                          </td>
                          <td style="width: 100px; color: blue">新质控品启用日期：</td>
                          <td style="width: 150px">
                              <el-date-picker v-model="qcsForm.startdt" type="date" placeholder="选择日期" style="width: 100%"></el-date-picker>
                          </td>
                          <td style="width: 100px; color: blue">新有效期：</td>
                          <td style="width: 150px">
                              <el-date-picker v-model="qcsForm.expriedt" type="date" placeholder="选择日期" style="width: 100%"></el-date-picker>
                          </td>
                      </tr>
                  </table>
              </el-form>
          </div>
          <div style="padding: 5px 0"></div>
          <div style="width: 100%" align="right">
              <span slot="footer" class="dialog-footer">
                  <el-checkbox v-model="batchnoChangeOldStop" size="mini">以新启用日期作为原质控品批号停用日期</el-checkbox>
                  <el-button style="margin-left: 10px;" @click="batchnoChangeOK_click()">更 换</el-button>

                  <el-button @click="batchnoChangeCancel_click()">取 消</el-button>
              </span>
          </div>
      </el-dialog>

      <el-dialog width="1100px" top="2px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="靶值设定" :visible.sync="targetSetDialogVisible">
          <div style="width: 100%; height: 502px; position: relative; border: 1px solid #ccc">
              <el-tabs type="border-card" v-model="targetSetTabsValue" @tab-click="tab_changed">
                  <el-tab-pane label="日期模式" name="1">
                      <div style="width: 100%; margin: 2px 0px">
                          <div style="float: left; width: 20%">
                              <vxe-table show-overflow ref="xTable51" height="460px" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData51" border size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @current-change="dateModeList_changed">
                                  <vxe-table-column type="index" title="NO." width="40"></vxe-table-column>
                                  <vxe-table-column field="begindt" title="靶值启用日期" width="150" :formatter="['toDateString', 'yyyy-MM-dd']" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                          <div style="float: right; width: 80%">
                              <vxe-table show-overflow ref="xTable52" height="460px" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData52" border size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :row-class-name="targetSetRowDateClassName" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" :key="table52key" @current-change="CurrentRowRight" @cell-dblclick="qcitemvalueDlg">
                                  <vxe-table-column field="seq" title="序号" width="40" align="center"></vxe-table-column>
                                  <!-- <vxe-table-column field="strselect" title="全选" width="50" header-align="center" align="center"> -->
                                  <vxe-table-column field="bselect" title="全选" width="40" header-align="center" align="center">
                                      <template v-slot:header="{ column }">
                                          <el-checkbox v-model="selectall" @change="chkselectall_change($event)"></el-checkbox>
                                      </template>
                                      <template v-slot="{row}">
                                          <!-- <el-checkbox field="bselect" v-if="row.strselect=='0'" :key="0"></el-checkbox>
                                          <el-checkbox field="bselect" v-else-if="row.strselect=='1'" checked="checked" :key="1" true-label="1" false-label="0"></el-checkbox> -->
                                          <el-checkbox v-model="row.bselect" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="rpt_itemname" title="报告项目" width="160" header-align="center"></vxe-table-column>
                                  <vxe-table-column field="tagvalue" title="靶值" width="70" :edit-render="{ name: 'input', events: { change: calcCvSd } }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="sd" title="SD" width="70" :edit-render="{ name: 'input', events: { change: calcCvTagvalue } }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="cv" title="CV" width="70" :edit-render="{ name: 'input', events: { change: calcSdTagvalue } }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="limithigh" title="失控上限" width="90" :edit-render="{ name: 'input' }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="limitlow" title="失控下限" width="90" :edit-render="{ name: 'input' }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="dynamictagvalue" title="启用动态靶值" width="100" header-align="center" align="center">
                                      <template v-slot="{row}">
                                          <el-checkbox v-model="row.dynamictagvalue" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="dynamictagvaluerule" title="动态靶值规则设置" width="120" header-align="center" align="right"><template v-slot="{row}">
                                          <el-input readonly v-model="row.dynamictagvaluerule" @click.native="OpenDynamicDlg(row)"></el-input>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="dynamictagvaluerule" title="动态靶值规则设置" width="120" header-align="center" align="right"><template v-slot="{row}">
                                          <el-input readonly v-model="row.dynamictagvaluerule" @click.native="OpenDynamicDlg(row)"></el-input>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="dynamictagvaluerule" title="动态靶值规则设置" width="120" header-align="center" align="right"><template v-slot="{row}">
                                          <el-input readonly v-model="row.dynamictagvaluerule" @click.native="OpenDynamicDlg(row)"></el-input>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="begindt" title="靶值启用日期" width="90" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                  <vxe-table-column field="lastmodifydt" title="最后修改时间" width="110" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                  <vxe-table-column field="lastmodifyuser" title="最后修改人" width="100" align="center"></vxe-table-column>
                                  <vxe-table-column field="stopdt" title="停用时间" width="90" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                  <vxe-table-column field="stopuser" title="停用者" width="100" align="center"></vxe-table-column>
                                  <vxe-table-column field="reagentmnfcturname" title="试剂厂商" width="120" header-align="center" align="left" :edit-render="{ name: 'input', autoselect: true }">
                                  </vxe-table-column>
                                  <vxe-table-column field="reagentbatchno" title="试剂批号" width="120" header-align="center" align="left" :edit-render="{ name: 'input' }">
                                  </vxe-table-column>
                                  <vxe-table-column field="calibratemnfcturname" title="校准品厂商" width="120" header-align="center" align="left" :edit-render="{ name: 'input', autoselect: true }">
                                  </vxe-table-column>
                                  <vxe-table-column field="calibrateno" title="校准品批号" width="120" header-align="center" align="left" :edit-render="{ name: 'input' }">
                                  </vxe-table-column>
                                  <vxe-table-column field="reagentvendorname" title="试剂供应商" width="120" header-align="center" align="left" :edit-render="{ name: 'input', autoselect: true }">
                                  </vxe-table-column>
                                  <vxe-table-column field="calibratevendorname" title="校准品供应商" width="120" header-align="center" align="left" :edit-render="{ name: 'input', autoselect: true }">
                                  </vxe-table-column>
                                  <vxe-table-column field="qcitemvalueid" title="靶值ID" width="80" header-align="center"></vxe-table-column>
                                  <vxe-table-column field="rpt_itemcode" title="项目代码" width="100" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </div>
                  </el-tab-pane>
                  <el-tab-pane label="项目模式" v-model="targetSetTabsValue" name="2">
                      <div style="width: 100%; margin: 2px 0px">
                          <div style="float: left; width: 30%">
                              <vxe-table show-overflow ref="xTable61" height="460px" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData61" border size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @current-change="itemModeList_changed" :key="table61key">
                                  <vxe-table-column type="index" title="NO." width="40"></vxe-table-column>
                                  <vxe-table-column field="seq" title="序号" width="60" sortable header-align="center" align="center"></vxe-table-column>
                                  <vxe-table-column field="rpt_itemname" title="报告项目" width="180" header-align="center"></vxe-table-column>
                                  <vxe-table-column field="rpt_itemcode" title="项目代码" width="100" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                          <div style="float: right; width: 70%">
                              <vxe-table show-overflow ref="xTable62" height="460px" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData62" border size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" :key="table62key">
                                  <!-- <vxe-table-column field="rpt_itemname" title="报告项目" width="160" header-align="center"></vxe-table-column> -->
                                  <vxe-table-column field="begindt" title="靶值启用日期" width="120" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                  <vxe-table-column field="tagvalue" title="靶值" width="80" :edit-render="{ name: 'input', events: { change: calcCvSd } }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="sd" title="SD" width="80" :edit-render="{ name: 'input', events: { change: calcCvTagvalue } }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="cv" title="CV" width="80" :edit-render="{ name: 'input', events: { change: calcSdTagvalue } }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="limithigh" title="失控上限" :edit-render="{ name: 'input' }" width="100" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="limitlow" title="失控下限" width="100" :edit-render="{ name: 'input' }" header-align="center" align="right"></vxe-table-column>
                                  <vxe-table-column field="lastmodifydt" title="最后修改时间" width="110" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                  <vxe-table-column field="lastmodifyuser" title="最后修改人" width="100" align="center"></vxe-table-column>
                                  <vxe-table-column field="stopdt" title="停用时间" width="90" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                                  <vxe-table-column field="stopuser" title="停用者" width="100" align="center"></vxe-table-column>
                                  <vxe-table-column field="rpt_itemcode" title="报告项目编码" width="160" header-align="center"></vxe-table-column>
                                  <vxe-table-column field="qcitemvalueid" title="靶值ID" width="80" header-align="center"></vxe-table-column>
                              </vxe-table>
                          </div>
                      </div>
                  </el-tab-pane>
              </el-tabs>
          </div>

          <span slot="footer" class="dialog-footer">
              <el-button icon="el-icon-search" @click="targetSetInit()">刷新</el-button>
              <el-button icon="el-icon-plus" @click="targetSetAdd()" v-if="targetSetTabsValue=='1'">新增&nbsp;/&nbsp;复制</el-button>
              <el-button icon="el-icon-plus" @click="targetSetAdd()" v-if="targetSetTabsValue=='2'">新增靶值启用日期</el-button>
              <el-button icon="el-icon-delete" @click="targetSetDelete()" v-if="targetSetTabsValue=='2'">删除靶值启用日期</el-button>
              <!-- <el-button icon="el-icon-document" v-if="targetSetTabsValue=='1'" @click="targetSetCopy()">复制到...</el-button> -->
              <el-button icon="el-icon-lock" v-if="!bLockCv" @click="!bLockCv?bLockCv = true:bLockCv = false">锁定CV</el-button>
              <el-button icon="el-icon-unlock" v-if="bLockCv" @click="!bLockCv?bLockCv = true:bLockCv = false">解除锁定CV</el-button>
              <el-button icon="el-icon-document" @click="targetSetCalc()">计算靶值</el-button>
              <el-button icon="el-icon-success" @click="targetSetSave_click()">保存</el-button>
              <el-button icon="el-icon-close" @click="targetSetClose()">退出</el-button>
          </span>

          <el-dialog :width="targetSetTabsValue=='1'?'435px':'230px'" top="2px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="输入靶值启用日期" :visible.sync="targetSetBegindtDialogVisible">
              <el-date-picker v-model="targetSetBegindt" type="date" placeholder="靶值启用日期" style="width:130px"></el-date-picker>
              <el-radio-group v-model="targetSetCopyFlag" style="padding-left: 15px" size="mini">
                  <el-radio-button label="0" v-if="targetSetTabsValue=='1'">仅新增</el-radio-button>
                  <el-radio-button label="1" v-if="targetSetTabsValue=='1'">不覆盖复制</el-radio-button>
                  <el-radio-button label="2" v-if="targetSetTabsValue=='1'">覆盖复制</el-radio-button>
              </el-radio-group>
              <span slot="footer" class="dialog-footer">
                  <el-button icon="el-icon-success" @click="targetSetBegindtOK()">确定</el-button>
                  <el-button icon="el-icon-close" @click="targetSetBegindtClose()">退出</el-button>
              </span>
          </el-dialog>
          <el-dialog width="350px" top="2px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="将 靶值数据 复制到 目标日期中" :visible.sync="targetSetCopyDialogVisible">
              <div style="width: 100%; padding: 10px 0px">
                  <span class="demonstration">目标日期：</span>
                  <el-date-picker v-model="targetSetCopyBegindt" type="date" placeholder="靶值启用日期" style="width: 70%"></el-date-picker>
              </div>
              <div style="width: 100%; padding: 5px 0px"></div>
              <el-checkbox v-model="targetSetCopyCover">覆盖目标日期中原有数据</el-checkbox>
              <span slot="footer" class="dialog-footer">
                  <el-button icon="el-icon-success" @click="targetSetCopyOK()">确定</el-button>
                  <el-button icon="el-icon-close" @click="targetSetCopyClose()">退出</el-button>
              </span>
          </el-dialog>
          <el-dialog width="1020px" top="2px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="计算靶值数据" :visible.sync="targetSetCalcDialogVisible">
              <table style="width: 100%;height:70px; font-size: 12px;" border="0">
                  <tr>
                      <td>日期:</td>
                      <td>
                          <el-date-picker v-model="targetSetCalcDt[0]" type="date" placeholder="开始日期" value-format="yyyy-MM-dd" style="width: 130px" :clearable="false"></el-date-picker>
                      </td>
                      <td>~</td>
                      <td>
                          <el-date-picker v-model="targetSetCalcDt[1]" type="date" placeholder="结束日期" value-format="yyyy-MM-dd" style="width: 130px" :clearable="false"></el-date-picker>
                      </td>
                      <td>
                          <el-radio-group v-model="targetSetCalcType" style="padding: 0px 10px" size="mini" @change="targetSetCalcType_changed">
                              <el-radio-button label="0">全部计算</el-radio-button>
                              <el-radio-button label="1">仅计算靶值</el-radio-button>
                              <el-radio-button label="2">仅计算SD</el-radio-button>
                          </el-radio-group>
                      </td>
                      <td>
                          <el-checkbox style="padding: 0px 0px 0px 0px" v-model="targetSetCalcInuse">包含非累积数据</el-checkbox>
                          <el-checkbox v-model="targetSetCalcDraw">包含非画图数据</el-checkbox>
                          <el-checkbox v-model="targetSetCalc3sd">包含3SD值</el-checkbox>
                      </td>
                      <td></td>

                  </tr>
                  <tr>
                      <td colspan="3 " style="text-align: left;">
                          <el-checkbox style=" padding: 0px 0px 0px 0px" v-model="bCalc1">每日数据仅计算一次</el-checkbox>
                      </td>
                      <td colspan="4" v-if="bCalc1">计算第 <el-input-number v-model="calcdaynum" controls-position="right" :min="1" :max="99" style="width:120px"></el-input-number>次数据</td>
                  </tr>
              </table>
              <!-- <div style="width: 100%; padding: 5px 0px">
                      日期： -->
              <!-- <el-date-picker v-model="targetSetCalcDt" type="daterange" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" @change="targetSetCalcQuery"></el-date-picker> -->
              <!-- 
                      <el-date-picker v-model="targetSetCalcDt[0]" type="date" placeholder="开始日期" value-format="yyyy-MM-dd" style="width: 130px" :clearable="false"></el-date-picker> ~
                      <el-date-picker v-model="targetSetCalcDt[1]" type="date" placeholder="结束日期" value-format="yyyy-MM-dd" style="width: 130px" :clearable="false"></el-date-picker> -->
              <!-- </div> -->
              <vxe-table style="float: left; width: 50%" show-overflow ref="xTable71" width="100%" height="420px" border :loading="loading" :select-config="xTable71CheckAll" :data.sync="tableData71" size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :row-class-name="targetSetRowClassName" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" @current-change="targetSetCalcRptitem_changed">
                  <vxe-table-column type="selection" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="rpt_itemname" title="报告项目" width="200" header-align="center"></vxe-table-column>
                  <vxe-table-column field="tagvalue" title="靶值" width="70" header-align="center" align="right" :edit-render="{ name: 'input', events: { change: calcCvSd } }"></vxe-table-column>
                  <vxe-table-column field="sd" title="SD" width="70" header-align="center" align="right" :edit-render="{ name: 'input', events: { change: calcCvTagvalue } }"></vxe-table-column>
                  <vxe-table-column field="cv" title="CV" width="70" header-align="center" align="right"></vxe-table-column>
              </vxe-table>
              <vxe-table style="float: right; width: 50%" show-overflow ref="xTable72" width="100%" height="420px" border :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData72" size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :row-class-name="targetSetRowClassName" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }">
                  <vxe-table-column field="resultdt" title="结果时间" width="100" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                  <vxe-table-column field="calculatevalue" title="计算结果" width="80" align="center"></vxe-table-column>
                  <vxe-table-column field="inuseflag" title="累计标志" width="80" align="center"></vxe-table-column>
                  <vxe-table-column field="drawflag" title="画图标志" width="80" align="center"></vxe-table-column>
                  <vxe-table-column field="calculatesd" title="计算SD" width="80" align="center"></vxe-table-column>
              </vxe-table>
              <span slot="footer" class="dialog-footer">
                  <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-search" @click="targetSetCalcQuery()">刷新</el-button>
                  <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-success" @click="targetSetCalcOK()">计算</el-button>
                  <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-success" @click="targetSetCalcSave()">保存</el-button>
                  <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-close" @click="targetSetCalcClose()">退出</el-button>
              </span>
          </el-dialog>
      </el-dialog>

      <!-- 动态靶值设定  -->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="动态靶值规则设定" :visible.sync="bOpenDynamic" width="800px">
          <div class="dynamictop">
              <div class="dymicvalue">动态靶值规则:</div>
              <el-input v-model="dynamictagvaluerule" style="width:200px" @keyup.enter.native="ShowDynamicRule()"></el-input>
              <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-success" @click="ShowDynamicRule()">显示规则</el-button>
              <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-success" @click="SaveDynamicOther()">应用到其他无规则项目</el-button>
              <el-button style="margin: 10px 10px 0px 5px" icon="el-icon-success" type="primary" @click="SaveDynamicRule">保存</el-button>
              <el-button icon="el-icon-close" style="margin: 10px 10px 0px 5px" @click="bOpenDynamic=false" type="warning">关闭</el-button>
          </div>
          <div class="dynamicbody" style="width:100%; height:550px">
              <div class="dynmicmode">
                  <div class="dynamicchild" :style="dynamiccheck1?'border: 2px solid rgb(102 160 233)':'border: 1px solid rgb(204, 204, 204);'">
                      <div class="tabtop">
                          <div v-if="dynamiccheck1" class="tab-title">动态靶值(使用)</div>
                          <div v-else class="tab-title">动态靶值</div>
                      </div>
                      <div class="datacenter">
                          <div v-for="msg in dynamictype1" :key="msg" style="over-flow:auto;font-size: 12.5px;">
                              <!-- <td style="width:30px;padding-left:5px">{{msg.seq}}.</td>
                  <td style="width:140px">{{msg.errotype}}</td> -->
                              <td style="height:20px"> <i class="el-icon-caret-right"></i>{{msg}}</td>
                          </div>
                      </div>
                  </div>
                  <div class="dynamicchild" :style="dynamiccheck2?'border: 2px solid rgb(102 160 233)':'border: 1px solid rgb(204, 204, 204);'">
                      <div class="tabtop">
                          <div v-if="dynamiccheck2" class="tab-title">定期计划(使用)</div>
                          <div v-else class="tab-title">定期计划</div>
                      </div>
                      <div class="datacenter" style="over-flow:auto;">
                          <div v-for="msg in dynamictype2" :key="msg" style="font-size: 12.5px;">
                              <!-- <td style="width:30px;padding-left:5px">{{msg.seq}}.</td>
                  <td style="width:140px">{{msg.errotype}}</td> -->
                              <td style="height:25px"> <i class="el-icon-caret-right"></i>{{msg}}</td>
                          </div>
                      </div>
                  </div>
              </div>
              <!-- <div style="background:#b1c9e2"> -->
              <el-tag class="dynmichelp" style="  font-size:14px;color:#606266;font-weight:550;padding-left: 10px;" effect="plain" type="info"> 1.填写规则：
                  <br><a class="dynmictxt"> 填入多个整数，用【,】隔开。如：0,20</a>
                  <br><a class="dynmictxt">【Num1】动态靶值从哪点开始计算 </a>
                  <br><a class="dynmictxt">【Num2】计算动态靶值点的数量</a>
                  <br><a class="dynmictxt">【Numn】当整数个数大于2时，除去第一个整数,其余整数表示到达累积数值时，计算1次靶值。</a>
                  <br><a class="dynmictitle1">1.【Num1,Num2 类型动态靶值维护方法】</a>
                  <br><a class="dynmictxt">① 例1 Num1 = 0 Num2 = 20</a>
                  <br><a class="dynmictxt">动态靶值不足20个点时，根据靶值启用日期内的所有点，逐个计算靶值。其中前2个点为动态靶值必须累积点，不参与判定。第21个点及之后的点的靶值基准，通过当前点的前20个点来计算。</a>
                  <br><a class="dynmictxt">② 例2 Num1 = 20 Num2 = 20</a>
                  <br style=""><a class="dynmictxt">前20个点均为动态靶值累积点，不参与计算，第21个点及之后的点的靶值基准，通过当前点的前20个点来计算。</a>
                  <br><a class="dynmictxt">③ 例3 Num1 = -1 Num2 = 20</a>
                  <br><a class="dynmictxt">特殊地，Num1 = -1时，记为不能计算动态靶值的点，使用静态靶值。</a>
                  <br><a class="dynmictxt">前20个点，都采用靶值启用日期的静态靶值计算，第21个点及之后的点的靶值基准，通过当前点的前20个点来计算。</a>
                  <br><a class="dynmictitle1">2.【Num1,Num2,,Num3,....Numn 类型定期计划维护方法】</a>
                  <br><a class="dynmictxt">① Num1-Num2点内的规则同上。</a>
                  <br><a class="dynmictxt">② Num2-Num3的点，一直沿用Num2计算的靶值标准，到Num3个点后,再计算一次靶值，...... 直至Numn，最后计算一次，该启用日期靶值固定，不再变化。</a>
              </el-tag>
              <!-- </div> -->
          </div>
      </el-dialog>
      <!-- 质控品双击弹窗 -->
      <!-- breagentmnfcturdlg 试剂厂商
      bcalibratemnfcturdlg 校准品厂商
      breagentvendordlg 试剂供应商
      bcalibratevendordlg 校准品供应商 -->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="试剂厂商" :visible.sync="breagentmnfcturdlg">
          <rm-pop-common ref="invvendor1" datatype="invvendorna" @change="reagentmnfcturChange" @cancel="breagentmnfcturdlg=false;" :multiple="false"></rm-pop-common>
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="校准品厂商" :visible.sync="bcalibratemnfcturdlg">
          <rm-pop-common ref="invvendor2" datatype="invvendorna" @change="calibratemnfcturChange" @cancel="bcalibratemnfcturdlg=false;" :multiple="false"></rm-pop-common>
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="试剂供应商" :visible.sync="breagentvendordlg">
          <rm-pop-common ref="invvendor3" datatype="invvendorna" @change="reagentvendorChange" @cancel="breagentvendordlg=false;" :multiple="false"></rm-pop-common>
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="校准品供应商" :visible.sync="bcalibratevendordlg">
          <rm-pop-common ref="invvendor4" datatype="invvendorna" @change="calibratevendorChange" @cancel="bcalibratevendordlg=false;" :multiple="false"></rm-pop-common>
      </el-dialog>

  </div>
</template>

<!----------------------------------  代码和显示l的华丽的分割线 ---------------------------------------------->

<script type="text/javascript">
import XEUtils from "xe-utils"; //引入工具类
// import { exists } from "fs";
XEUtils.mixin({
  // 自定义全局的格式化处理函数
  formatSelect(cellValue, list) {
      let item = list.find((item) => item.value == cellValue);
      return item ? item.label : "";
  },
});
export default {
  name: "LIS511",
  data() {
      return {
          loading: false,
          dialogTableVisible: false, //弹窗是否打开，默认关闭
          bLockCv: false,
          instrId: 0, //仪器ID
          instrName: "", //仪器名称
          batchno: "", //查询条件：批号
          qclevel: "", //查询条件：水平
          batchno1: "", //查询条件：实际批号
          checkreportflag: "1", //查询条件：报告依据 
          showallbatch: "0", ////查询条件：显示所有批号
          txtsearch: "",
          rpt_itemcode: "",
          tableData1: [], //左边liist 数据
          tableData2: [], //右边detail的Grid窗口数据
          tableData3: [], //维护数据弹窗 中grid的数据
          tableData4: [], //质控数据复制 弹窗中grid的数据
          deleteDialogVisible: false, //删除确认弹窗
          //设定Grid窗口 按回车键跳到下一列
          keyConfig: {
              isArrow: true,
              isDel: true,
              isTab: true,
              isEdit: true,
              editMethod: ({ seq, row, rowIndex, column, columnIndex, cell }) => {},
          },
          xTable71CheckAll: { checkAll: false },
          qcsForm: {}, //弹窗维护中的数据
          copyForm: {}, //自身复制的数据
          qcsDisplay: {}, //右边显示的数据
          rules: {}, //弹窗表单的校验规则
          findRow: 0, //新增时，返回左边list的 row （行数据集合）
          detailAddDialogVisible: false, //新增弹窗中，新增明细时弹窗，可多选
          DelIndex: -1, //删除明细按钮使用
          qcCopyDialogVisible: false, //质控数据复制弹窗显示
          qcCopyOverride: 0, //质控数据复制弹窗 覆盖原有数据
          qcCopyItemvalue: "0", //质控数据复制弹窗 带带靶值复制
          batchnoChangeDialogVisible: false, //更换批号弹窗显示
          batchnoChangeOldStop: true, //更换批号弹窗-以以新启用日期作为原质控品的停用日期
          targetSetDialogVisible: false, //靶值设定弹窗显示
          targetSetTabsValue: "1", //靶值设定 Tabs选择 '1' 日期模式  '2'项目模式
          tableData51: [], //靶值设定、日期模式中，右边列表
          tableData52: [], //靶值设定、日期模式中，右边列表
          tableData61: [], //靶值设定、项目模式中，左边列表
          tableData62: [], //靶值设定、项目模式中，右边列表
          targetSetBegindtDialogVisible: false, //靶值设定: 新增启用日期弹窗中也使用
          targetSetBegindt: null, //靶值设定 启用日期 ，新增启用日期弹窗中也使用
          targetSetCopyDialogVisible: false, //靶值设定：弹窗显示
          targetSetCopyBegindt: null, //靶值设定：复制靶值弹窗、目标数据
          targetSetCopyFlag: "0", //靶值设定:新增靶值弹窗 0:仅新增，1不覆盖复制，2覆盖复制
          targetSetCopyCover: false, //靶值设定：复制靶值弹窗、覆盖原有数据
          targetSetCalcDialogVisible: false, //靶值设定-靶值计算弹窗
          tableData71: [], //靶值设定-靶值计算弹窗，左边列表
          tableData72: [], //靶值设定-靶值计算弹窗，右边列表
          targetSetCalcDt: [], //靶值设定-靶值计算弹窗：起始结束日期
          targetSetCalcInuse: false, //靶值设定-靶值计算弹窗：包含非累计数据
          bCalc1: false, //靶值设定-靶值计算弹窗：仅计算1次标记
          targetSetCalcDraw: false, //靶值设定-靶值计算弹窗：包含非画图数据
          targetSetCalc3sd: false, //靶值设定-靶值计算弹窗：包含3sd值
          targetSetCalcType: "0", //靶值设定-靶值计算弹窗：仅计算靶值、仅计算SD
          ItemJudgeShow: false, //右侧TAB定性质控
          tableDataJudge: [], //右侧TAB定性质控数据
          tableDataJudgeKey: 1, // //右侧TAB定性质控数据刷新标记
          ItemJudgeShowDialog: false, //弹窗定性质控
          tableDataJudgeDialog: [], //弹窗定性质控数据
          qclevelList: [], //维护弹窗中的水平下拉框，
          table51key: 1, //强制刷新标记
          table52key: 1, //强制刷新标记
          table61key: 1, //强制刷新标记
          table62key: 1, //强制刷新标记
          calcdaynum: 1, //计算每天第几次的数据 
          table62height: "432px",
          westgardOption: [
              { label: "Westgard", value: 1 },
              { label: "绝对值", value: 2 },
              { label: "百分比", value: 3 },
              { label: "定性质控", value: 4 },
              { label: "血型鉴定", value: 11 },
              { label: "抗体筛查", value: 12 },
              { label: "交叉配血", value: 13 },
              { label: "直接coombs", value: 14 },
          ],
          dgList: [
              { label: "", value: "0" },
              { label: "√", value: "1" },
          ],
          controlstatusList: [
              { label: "失控", value: "0" },
              { label: "在控", value: "1" },
              { label: "未设置", value: null },
          ],
          //以下为分割条和窗口界面布局参数
          leftwidth: 0,
          rightwidth: 600,
          topheight: 75,
          bottomheight: 0,
          dialogTestVisible: false,
          temprptitem: {},
          selectall: true, //全选
          addFlag: false, //靶值设置-日期模式-选中日期是否为 新增日期
          addData: [], //靶值设置-日期模式-新增 启用日期数组
          username: this.$tool.getSession(this.$tool.loginusername),
          selectChangeArr: [],
          valueitemrow: {}, //项目模式 计算靶值
          bSelectCopyMode: false,
          bCopySelfAdd: false,
          //定性质控
          itemcopyflag: false,
          itemJugeTempData: [],
          //动态靶值窗口
          bOpenDynamic: false,
          dynamictagvaluerule: "",
          dynamiccheck1: false,
          dynamiccheck2: false,
          dynamictype1: [],
          dynamictype2: [],
          itemvaluerow: {}, //靶值当前行
          qcsSelectRow: {}, //质控品当前选中行
          breagentmnfcturdlg: false, //试剂厂商
          bcalibratemnfcturdlg: false, //校准品厂商
          breagentvendordlg: false, //试剂供应商
          bcalibratevendordlg: false, //校准品供应商
      };
  },
  computed: {
      com_checkreportflagDisplay: function () {
          return this.qcsDisplay.checkreportflag == "1" ? true : false;
      },
      com_startdt: function () {
          return XEUtils.toDateString(this.qcsDisplay.startdt, "yyyy-MM-dd");
      },
      com_expriedt: function () {
          return XEUtils.toDateString(this.qcsDisplay.expriedt, "yyyy-MM-dd");
      },
      com_stopdt: function () {
          return XEUtils.toDateString(this.qcsDisplay.stopdt, "yyyy-MM-dd");
      },
      com_inputdt: function () {
          return XEUtils.toDateString(this.qcsDisplay.inputdt, "yyyy-MM-dd");
      },
      // dynamictagvaluerule: function () {
      //     var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
      //     reg.test(dynamictagvaluerule)
      //     return  dynamictagvaluerule.Math(RegExp("[\\u4E00-\\u9FFF]+", "g"));
      // },
      com_qcCopyOverride: {
          // getter
          get: function () {
              return this.qcCopyOverride == 1 ? true : false;
          },
          // setter
          set: function (newValue) {
              if (newValue) {
                  this.qcCopyOverride = 1;
              } else {
                  this.qcCopyOverride = 0;
              }
          },
      },
  },
  //html加载完成之前，执行。执行顺序：父组件-子组件
  created() {
      this.targetSetBegindt = new Date();
  },
  //.html加载完成后执行。执行顺序：子组件-父组件
  mounted() {},
  updated() {}, //数据变化时加载事件
  watch: {
      instrId(val) {
          this.initialList();
      },
  },
  methods: {
      ItemJudgeCopy() {
          this.itemJugeTempData = XEUtils.clone(this.tableDataJudgeDialog, true);
          this.$message({
              message: "复制成功。",
              type: "success",
          });
          this.itemcopyflag = true;
      },
      ItemJudgePaste() {
          this.$message({
              message: "粘贴成功。",
              // type: "success",
          });
          this.tableDataJudgeDialog = this.itemJugeTempData;
      },
      formatterCheckreportflag({ cellValue }) {
          return cellValue === "1" ? "是" : "";
      },
      formatterControlStatus({ cellValue }) {
          return cellValue === "1" ? "在控" : cellValue === "0" ? "失控" : "";
      },
      //按value返回对应的label值
      getSelectLabel(value, list, valueProp = "value", labelField = "label") {
          for (let index in list) {
              if (list[index].value == value) {
                  return list[index].label;
              }
          }
          return null;
      },

      //查询左边list
      labinstrumentchange(id, name) {
          this.instrId = id;
          this.instrName = name;
          // this.initialList();
      },

      //初始化数据
      resetData() {
          this.tableData1 = [];
          this.tableData2 = [];
          this.tableData3 = [];
          this.qcsForm = {};
          this.qcsDisplay = {};
      },

      //打开窗时初始化
      initialList() {
          this.loading = true;
          this.resetData();
          this.$tool //主表查询
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "query",
                      instrid: this.instrId, //查询条件：仪器
                      batchno: this.batchno, //查询条件：批号
                      qclevel: this.qclevel, //查询条件：水平
                      batchno1: this.batchno1, //查询条件：实际批号
                      // inuse: this.inuse, //查询条件：是否在用
                      checkreportflag: this.checkreportflag, //查询条件：报告依据
                      showallbatch: this.showallbatch, //查询条件：显示所有数据
                  },
              })
              .then((response) => {
                  this.ItemJudgeShow = false;
                  this.tableData1 = response.Data;
                  this.loading = false;
                  //list表格数据加载完成后执行
                  this.$nextTick(() => {
                      //若有指定行加载指定行  新增，修改情况下，加载指定行，否则加载第一行（查询模式下）
                      if (this.findRow > 0) {
                          var selectrow = this.$refs.xTable1.tableData.filter((row) => {
                              return row.qcid == this.findRow;
                          })[0];
                      } else {
                          var selectrow = this.$refs.xTable1.getData(0);
                      }
                      if (selectrow) {
                          this.$refs.xTable1.setCurrentRow(selectrow); //高亮行
                          this.$refs.xTable1.scrollToRow(selectrow); //滚动到行
                          this.masterRowChanged(selectrow); //查询右边明细表
                          this.findRow = 0;
                      } else {
                          this.$refs.xTable1.setCurrentRow(null); //这个不会自动清空
                      }
                  });
              })
              .catch((e) => {
                  this.loading = false;
                  console.log("error", e);
              });

          this.$tool //主表查询
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "qclevelList",
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") this.qclevelList = response.Data;
              })
              .catch((e) => {});
      },
      //左边list窗口行变换事件
      masterRowChangedEvent({ row }) {
          this.ItemJudgeShow = false;
          this.masterRowChanged(row);
      },
      //左边list行变换执行
      masterRowChanged(row) {
          this.qcsDisplay = row; //给右边Tab显示用的数据
          this.detailRetrieve(this.qcsDisplay.qcid);
      },
      //右边tab行点击事件
      qcTableClick2(row) {
          this.qcTableClick({ row });
      },
      qcTableClick({ row }) {
          if (row.qcruletype == "4") {
              this.QueryItemJudge(row, 1);
              this.$nextTick(() => {
                  this.ItemJudgeShow = true;
              });
          } else {
              this.ItemJudgeShow = false;
          }
      },
      //维护弹窗中下方表格的行点击事件
      qcTableClickDialog2(row, column) {
          this.qcTableClickDialog({ row, column }, "showqt4");
      },
      //质控品弹窗
      qcTableClickDialog({ row, column }, flag) {
          if (flag != "showqt4") {
              if (column.property == "reagentmnfcturname") {
                  this.qcsSelectRow = row;
                  this.breagentmnfcturdlg = true;
              } else if (column.property == "calibratemnfcturname") {
                  this.qcsSelectRow = row;
                  this.bcalibratemnfcturdlg = true;
              } else if (column.property == "reagentvendorname") {
                  this.qcsSelectRow = row;
                  this.breagentvendordlg = true;
              } else if (column.property == "calibratevendorname") {
                  this.qcsSelectRow = row;
                  this.bcalibratevendordlg = true;
              }
          }
          if (row.qcruletype == "4") {
              this.QueryItemJudge(row, 2);
              this.$nextTick(() => {
                  this.ItemJudgeShowDialog = true;
              });
          } else {
              this.ItemJudgeShowDialog = false;
          }
      },
      qcitemvalueDlg({ row, column })
      {
             if (column.property == "reagentmnfcturname") {
                  this.qcsSelectRow = row;
                  this.breagentmnfcturdlg = true;
              } else if (column.property == "calibratemnfcturname") {
                  this.qcsSelectRow = row;
                  this.bcalibratemnfcturdlg = true;
              } else if (column.property == "reagentvendorname") {
                  this.qcsSelectRow = row;
                  this.breagentvendordlg = true;
              } else if (column.property == "calibratevendorname") {
                  this.qcsSelectRow = row;
                  this.bcalibratevendordlg = true;
              }
      },
      //质控品弹窗保存供应商
      //试剂厂商保存
      reagentmnfcturChange(code, name) {
          this.qcsSelectRow.reagentmnfcturcode = code;
          this.qcsSelectRow.reagentmnfcturname = name;
          this.breagentmnfcturdlg = false;
      },
      //校准品厂商保存
      calibratemnfcturChange(code, name) {
          this.qcsSelectRow.calibratemnfcturcode = code;
          this.qcsSelectRow.calibratemnfcturname = name;
          this.bcalibratemnfcturdlg = false;
      },
      //试剂供应商保存
      reagentvendorChange(code, name) {
          this.qcsSelectRow.reagentvendorcode = code;
          this.qcsSelectRow.reagentvendorname = name;
          this.breagentvendordlg = false;
      },
      //校准品供应商保存
      calibratevendorChange(code, name) {
          this.qcsSelectRow.calibratevendorcode = code;
          this.qcsSelectRow.calibratevendorname = name;
          this.bcalibratevendordlg = false;
      },
      //维护弹窗界面的 弹窗 ， 下方明细窗口再弹窗输入项目
      detailInsertItem(row) {
          this.temprptitem = row;
          this.dialogTestVisible = true;
          this.$refs.qcinstritem2.refreshdata();
      },
      //维护弹窗界面的 增加 按钮触发
      masterAdd() {
          if (this.instrId > 0) {
              this.dialogTableVisible = true;
              this.qcsForm = { checkreportflag: "1" }; 
              //this.qcsForm.qclevel = "";
              this.tableData3 = [];
              //this.$refs.qclevelpop.refreshdata();
              this.ItemJudgeShowDialog = false;
          } else {
              this.$message({
                  message: "请先选择仪器！",
                  type: "error",
              });
          }
      },

      //弹窗 修改按钮触发
      masterUpdate() {
          var selrow = this.$refs.xTable1.getCurrentRow();
          if (selrow) {
              this.dialogTableVisible = true;
              this.qcsForm = XEUtils.clone(selrow, true); //给弹窗维护用的数据 ，
              this.tableData3 = XEUtils.clone(this.tableData2, true);
              //this.ItemJudgeShowDialog = false;
              this.$nextTick(() => {
                  this.loadFirstRow(this.$refs.xTable3, this.qcTableClickDialog2);
              });
          } else {
              this.$message({
                  message: "请先选中要修改的数据！",
                  type: "error",
              });
          }
      },

      QueryItemJudge(row, type) {
          if (type == 1) {
              this.tableDataJudge = [];
          } else {
              this.tableDataJudgeDialog = [];
          }
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "queryItemJudge",
                      qcid: row.qcid,
                      instrId: this.instrId,
                      rpt_itemcode: row.rpt_itemcode,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      if (type == 1) {
                          this.tableDataJudgeKey++;
                          this.tableDataJudge = response.Data;
                      } else {
                          this.tableDataJudgeDialog = response.Data;
                      }
                  }
              });
      },
      //弹窗 删除按钮触发
      masterDelete() {
          var selrow = this.$refs.xTable1.getCurrentRow();
          if (selrow) {
              this.$tool
                  .request({
                      url: "LIS/LIS5/LIS511",
                      method: "post",
                      data: {
                          action: "deleteValid",
                          qcid: selrow.qcid,
                          rpt_itemcode: "",
                      },
                  })
                  .then((response) => {
                      if (response.errcode == "1") {
                          this.deleteDialogVisible = true; //弹出询问是否可删除的窗口    建议以后做成公共控件
                      } else {
                          this.$message({
                              dangerouslyUseHTMLString: true,
                              message: "删除 " + selrow.qcname + "  /  " + selrow.batchno + "  /  " + selrow.qclevel + " 失败！<br/><br/>详细信息：" + response.errmsg,
                              type: "warning",
                          });
                      }
                  });
          } else {
              this.$message({
                  message: "请先选中要删除的数据！",
                  type: "error",
              });
          }
      },

      //确认删除按钮
      masterDeleteOK() {
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "delete",
                      saveinfo: this.qcsDisplay,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$message({
                          message: "删除" + this.qcsDisplay.qcname + "成功！",
                          type: "success",
                      });
                      this.initialList(); //刷新主界面
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "删除" + this.qcsDisplay.qcname + "  /  " + this.qcsDisplay.batchno + "  /  " + this.qcsDisplay.qclevel + "失败！<br/><br/>详细信息：" + response.errmsg,
                          type: "warning",
                      });
                  }
                  this.deleteDialogVisible = false;
              });
      },

      //取消删除按钮
      masterDeleteCancll() {
          this.deleteDialogVisible = false;
      },

      //右边 Tab 明细窗口刷新数据
      detailRetrieve(qcid) {
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "queryDetail",
                      qcid: qcid,
                  },
              })
              .then((response) => {
                  this.tableData2 = response.Data;
                  console.log("🤣  this.tableData2", this.tableData2);
                  this.tableData2.sort((a, b) => {
                      return a.seq - b.seq;
                  });
                  this.loading = false;
                  this.loadFirstRow(this.$refs.xTable2, this.qcTableClick2);
                  if (this.tableData2.length > 0 && this.tableData2[0].qcruletype == "4") this.ItemJudgeShow = true;
              })
              .catch((e) => {
                  this.loading = false;
                  console.log("error", e);
              });
      },

      // 提交前校验数据，
      qcsValid() {
          var msg; //校验表头数据
          msg = this.valid(this.qcsForm.qcname, "质控品名称 必须填写！");
          if (msg) return msg;
          msg = this.valid(this.qcsForm.batchno, "批号  必须填写！");
          if (msg) return msg;
          msg = this.valid(this.qcsForm.qclevel, "水平 必须填写！");
          if (msg) return msg;
          msg = this.valid(this.qcsForm.startdt, "质控品启用日期 必须填写！");
          if (msg) return msg;
          msg = this.valid(this.qcsForm.expriedt, "有效期 必须填写！");
          if (msg) return msg;
          //校验明细数据
          var record = this.$refs.xTable3.tableData;
          for (let i = 0, len = record.length; i < len; i++) {
              msg = this.valid(record[i].rpt_itemcode, "第" + (i + 1) + "行 质控品名称 必须填写！");
              if (msg) return msg;
              msg = this.valid(record[i].startdt, "第" + (i + 1) + "行 靶值启用日期 必须填写！");
              if (msg) return msg;
              msg = this.valid(record[i].expriedt, "第" + (i + 1) + "行 有效期 必须填写！");
              if (msg) return msg;
          }
      },

      save() {
          if (this.qcsValid()) return false;
          //待校验完成后才保存数据
          this.$nextTick(() => {
              this.saveData();
          });
      },

      //保存数据
      saveData() {
          let record = this.$refs.xTable3.tableData;
          record = record.sort((a, b) => a.seq - b.seq);
          for (let i = 0, len = record.length; i < len; i++) {
              record[i].seq = (i + 1) * 10;
              record[i].expriedt = XEUtils.toDateString(record[i].expriedt, "yyyy-MM-dd") + " 23:59:59";
              record[i].startdt = XEUtils.toDateString(record[i].startdt, "yyyy-MM-dd");
              record[i].stopdt = XEUtils.toDateString(record[i].stopdt, "yyyy-MM-dd");
          }
          this.qcsForm.expriedt = XEUtils.toDateString(this.qcsForm.expriedt, "yyyy-MM-dd") + " 23:59:59";
          this.qcsForm.startdt = XEUtils.toDateString(this.qcsForm.startdt, "yyyy-MM-dd");
          this.qcsForm.stopdt = XEUtils.toDateString(this.qcsForm.stopdt, "yyyy-MM-dd");
          var recordset = this.$refs.xTable3.getRecordset(); //定义 表格提交数据
          console.log("🤣  recordset", recordset);
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "save",
                      instrId: this.instrId,
                      saveinfo: this.qcsForm,
                      oldinfo: this.qcsDisplay,
                      urec: recordset,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$message({
                          message: "保存成功！",
                          type: "success",
                      });
                      this.findRow = response.keyId; //保存成功后 ，返回数据定义 ，以便左边list表格的 行定位
                      this.initialList(); //刷新 界面
                      this.dialogTableVisible = false;
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "保存失败！<br/><br/>详细信息：" + response.errmsg,
                          type: "warning",
                      });
                  }
              });
      },

      cancel() {
          this.dialogTableVisible = false;
      },
      //维护弹窗中 明细中的开始时间批量赋值
      startdtcopy_click() {
          for (var i = 0; i < this.$refs.xTable3.getTableData().fullData.length; i++) {
              this.$refs.xTable3.getTableData().fullData[i]["startdt"] = this.qcsForm.startdt;
          }
      },
      expriedtcopy_click() {
          for (var i = 0; i < this.$refs.xTable3.getTableData().fullData.length; i++) {
              this.$refs.xTable3.getTableData().fullData[i]["expriedt"] = this.qcsForm.expriedt;
          }
      },
      //维护弹窗中 明细中的停用时间批量赋值
      stopdtcopy_click() {
          for (var i = 0; i < this.$refs.xTable3.getTableData().fullData.length; i++) {
              this.$refs.xTable3.getTableData().fullData[i]["stopdt"] = this.qcsForm.stopdt;
          }
      },
      //维护弹窗的 增加明细按钮
      detailAdd() {
          ////维护弹窗的下方明细窗口中  插入一行
          var records = {};
          records.checkreportflag = "1";
          records.qcid = this.qcsForm.qcid;
          records.seq = this.$refs.xTable3.getTableData().fullData.length * 10 + 10;
          if (this.qcsForm.startdt) records.startdt = this.qcsForm.startdt;
          if (this.qcsForm.expriedt) records.expriedt = this.qcsForm.expriedt;
          // if (this.qcsForm.stopdt) records.stopdt = this.qcsForm.stopdt;

          this.$refs.xTable3.insertAt(records, -1); //在最后添加一行
          var curow = this.$refs.xTable3.getTableData().fullData[this.$refs.xTable3.getTableData().fullData.length - 1]; //获取 新加的行对象 row 数据集合
          this.$refs.xTable3.setCurrentRow(curow); //高亮显示行
          this.$nextTick(() => {
              this.$refs.xTable3.scrollToRow(curow); //待数据加载完成后，延迟 滚动 到行
          });
      },
      detailAddSelect() {
          //console.log("qcsForm", this.qcsForm.qclevel);
          //维护弹窗的下方明细窗口中 弹窗多选增加
          this.detailAddDialogVisible = true;
          this.$refs.qcinstritem1.refreshdata();
      },
      detailAddItems(rptitemcodeinfos) {
          var seq = 0;
          var seqk = 0;
          var ishave = false;
          var datarecord = this.$refs.xTable3.tableData;
          let initdata = [];
          for (var i = 0; i < rptitemcodeinfos.length; i++) {
              if (datarecord.length > 0) {
                  try {
                      datarecord.forEach((item) => {
                          if (item.rpt_itemcode == rptitemcodeinfos[i].rpt_itemcode) {
                              ishave = true;
                              throw Error();
                          } else {
                              ishave = false;
                          }
                          if (Number(item.seq) / 10 > seq) {
                              seq = Number(item.seq) / 10;
                          }
                      });
                  } catch (e) {}
              }
              if (ishave) {
                  continue;
              }
              seq++;
              seqk = seq * 10;
              let addrecord = {
                  seq: seqk,
                  qcid: this.qcsForm.qcid, //质控品id
                  checkreportflag: "1", //报告依据
                  rpt_itemcode: rptitemcodeinfos[i].rpt_itemcode, //报告项目代码
                  rpt_itemname: rptitemcodeinfos[i].rpt_itemname, //报告项目代码
                  startdt: this.qcsForm.startdt, //启用日期
                  expriedt: this.qcsForm.expriedt, //有效期
              };
              initdata.push(addrecord);
          }
          this.$refs.xTable3.insert(initdata);
          //console.log("qcsForm", this.qcsForm.qclevel);
          this.detailAddDialogVisible = false;
      },
      //维护弹窗的 删除明细按钮
      detailDelete_clicked() {
          var delrow = this.$refs.xTable3.getCurrentRow();
          if (delrow) {
              var rpt_itemcode = delrow.rpt_itemcode;
              if (rpt_itemcode == null) {
                  this.detailDelete();
                  return;
              }
          } else {
              this.$message({
                  message: "请先选中要删除的数据！",
                  type: "warning",
              });
              return;
          }
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "deleteValid",
                      qcid: this.qcsForm.qcid,
                      rpt_itemcode: rpt_itemcode,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.detailDelete();
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "删除 " + delrow.rpt_itemname + "  失败！<br/><br/>详细信息：" + response.errmsg,
                          type: "warning",
                      });
                  }
              });
      },
      //校验后再删除
      detailDelete() {
          this.deleteRow(this.$refs.xTable3);
      },
      //主窗口 质控数据 复制按钮  打开弹窗
      qcCopy_click() {
          this.txtsearch = "";
          this.tableData4 = [];
          this.qcCopyOverride = 0;
          if (this.$refs.xTable1.getCurrentRow()) {
          } else {
              this.$message({
                  message: "请先选中待复制的数据！",
                  type: "info",
              });
              return;
          }
          this.bSelectCopyMode = true;
      },
      CopyByAnother() {
          this.bSelectCopyMode = false;
          this.qcCopyDialogVisible = true;
          this.QcCopyRetrieve();
      },
      CopyInstrSelfAdd() {
          this.bSelectCopyMode = false;
          this.copyForm = {
              qcname: "",
              batchno: "",
              qclevel: this.qcsDisplay.qclevel,
              startdt: this.qcsDisplay.startdt,
              stopdt: this.qcsDisplay.stopdt,
              expriedt: this.qcsDisplay.expriedt,
              cpstart: "0",
              // cpstop:"0",
              cpexprie: "0",
          };
          this.bCopySelfAdd = true;
      },
      //质控品数据复制  快速检索
      qcCopySearch_change() {
          this.QcCopyRetrieve();
      },
      //质控品数据复制 弹窗 刷新数据
      QcCopyRetrieve() {
          var queryString = this.txtsearch.trim();
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "qcCopyQuery",
                      instrId: this.instrId,
                      queryString: queryString,
                  },
              })
              .then((response) => {
                  this.tableData4 = response.Data;
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //复制质控品数据到 其他仪器中
      qcCopyOK_click() {
          var selectRows = this.$refs.xTable4.getSelectRecords();
          if (selectRows) {
              var targetInstrIds = [];
              for (let index in selectRows) {
                  let item = {
                      instrid: selectRows[index].instrid,
                      instrname: selectRows[index].instrname,
                  };
                  targetInstrIds[index] = item;
              }
          } else {
              return;
          }
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "qcCopy",
                      targetInstrIds: targetInstrIds,
                      qcsData: this.qcsDisplay,
                      qcCopyOverride: this.qcCopyOverride,
                      qcCopyItemvalue: this.qcCopyItemvalue,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.qcCopyDialogVisible = false;
                      this.$message({
                          message: "复制数据成功！",
                          type: "success",
                      });
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "复制失败！<br/><br/>详细信息：" + response.errmsg,
                          type: "warning",
                      });
                  }
              })
              .catch((e) => {
                  console.log("error", e);
                  this.$message({
                      message: "复制失败！",
                      type: "warning",
                  });
              });
      },
      //复制质控品数据到 当前仪器
      qcCopySelf_click() {
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "qcCopyInstrSelf",
                      qcsData: this.qcsDisplay,
                      ...this.copyForm,
                      // qcCopyOverride: this.qcCopyOverride,
                      // qcCopyItemvalue: this.qcCopyItemvalue,
                  },
              })
              .then((res) => {
                  if (res.errcode == "1") {
                      this.bCopySelfAdd = false;
                      this.$message({
                          message: "复制数据成功！",
                          type: "success",
                      });
                      this.initialList();
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "复制失败！<br/><br/>详细信息：" + res.errmsg,
                          type: "warning",
                      });
                  }
              })
              .catch((e) => {
                  console.log("error", e);
                  this.$message({
                      message: "复制失败！",
                      type: "warning",
                  });
              });
      },
      qcCopyCancel_click() {
          this.qcCopyDialogVisible = false;
      },
      batchnoChange_click() {
          this.qcsForm = {};
          if (this.qcsDisplay.qcid > 0) {
              this.$nextTick(() => {
                  this.batchnoChangeDialogVisible = true;
              });
          } else {
              this.$message({
                  message: "请先选中待更换的质控品！",
                  type: "info",
              });
          }
      },
      batchnoChangeOK_click() {
          //  校验数据，
          var msg;
          msg = this.valid(this.qcsForm.batchno, "新批号 必须填写！");
          if (msg) return msg;
          msg = this.valid(this.qcsForm.startdt, "新质控品启用日期  必须填写！");
          if (msg) return msg;
          msg = this.valid(this.qcsForm.expriedt, "新有效期 必须填写！");
          if (msg) return msg;
          this.qcsForm.expriedt = XEUtils.toDateString(this.qcsForm.expriedt, "yyyy-MM-dd") + " 23:59:59";
          this.qcsForm.startdt = XEUtils.toDateString(this.qcsForm.startdt, "yyyy-MM-dd");
          // if(vstartdt>vcom_startdt)
          // msg = "新启用日期 必须大于原启用日期";
          // if (msg) return msg;
          // if(vexpriedt<vstartdt)
          // msg = "新有效期 必须大于新启用日期";
          // if (msg) return msg;
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "batchnoChange",
                      instrId: this.instrId,
                      qcsData: this.qcsDisplay,
                      qcsForm: this.qcsForm,
                      oldstopflag: this.batchnoChangeOldStop == true ? "1" : "0",
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.batchnoChangeDialogVisible = false;
                      this.$message({
                          message: "更换批号成功！",
                          type: "success",
                      });
                      this.initialList();
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "更换批号失败！<br/><br/>详细信息：" + response.errmsg,
                          type: "warning",
                      });
                  }
              });
      },
      batchnoChangeCancel_click() {
          this.batchnoChangeDialogVisible = false;
      },
      targetSet_click() {
          if (this.$refs.xTable1.getCurrentRow()) {
          } else {
              this.$message({
                  message: "请先选中待设定靶值的数据！",
                  type: "info",
              });
              return;
          }
          this.targetSetTabsValue = "1";
          this.bLockCv = false;
          this.targetSetDialogVisible = true;
          this.$nextTick(() => {
              this.targetSetInit();
              this.targetSetItemModeList();
          });
      },

      //右边设定靶值窗口标签切换
      tab_changed(tab, event) {
          var a = tab.value;
          if (tab.paneName == "1") {
              //日期模式
              this.tablekey51++;
              this.tablekey52++;
          }
          if (tab.paneName == "2") {
              //项目模式
              this.tablekey61++;
              this.tablekey62++;
          }
      },
      targetSetInit() {
          if (this.targetSetTabsValue == "1") this.targetSetDateModeList();
          if (this.targetSetTabsValue == "2") this.targetSetItemModeList();
      },
      //日期模式，从数据库加载左边列表数据
      targetSetDateModeList() {
          this.tableData51 = [];
          this.$refs.xTable51.setCurrentRow(null); //这个不会自动清空
          this.tableData52 = [];
          this.$refs.xTable52.setCurrentRow(null); //这个不会自动清空
          this.addFlag = false; 
          this.addData = []; 
          var selrow = this.$refs.xTable1.getCurrentRow();
          if (selrow) {
          } else {
              this.$message({
                  message: "请先选中要计算靶值的质控品！",
                  type: "info",
              });
              return;
          }
          var qcid = selrow.qcid;
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "targetSetDateModeList",
                      qcid: qcid,
                  },
              })
              .then((response) => {
                  this.tableData51 = response.Data;
                  // this.selectall = true;
                  this.$nextTick(() => {
                      this.loadFirstRow(this.$refs.xTable51, this.dateModeListChanged);
                  });
                  // //list表格数据加载完成后执行
                  // this.$nextTick(() => {
                  //   // 加载第一行
                  //   var selectrow = this.$refs.xTable51.getData(0);
                  //   if (selectrow) {
                  //     this.$refs.xTable51.setCurrentRow(selectrow); //高亮行
                  //     this.$refs.xTable51.scrollToRow(selectrow); //滚动到行
                  //     this.dateModeListChanged(selectrow); //查询  明细
                  //   } else {
                  //     this.$refs.xTable51.setCurrentRow(null); //这个不会自动清空
                  //   }
                  // });
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },

      //日期模式 list窗口行变换事件
      dateModeList_changed({ row }) {
          this.dateModeListChanged(row);
      },
      CurrentRowRight(row) {},
      //日期模式 list行变换执行
      dateModeListChanged(row) {
          let dateModeListRow = row; //给右边Tab显示用的数据
          if (this.addData.indexOf(XEUtils.toDateString(row.begindt, "yyyy-MM-dd")) > -1) {
              this.addFlag = true;
          } else {
              this.addFlag = false;
          }
          this.dateModeRetrieve(this.$refs.xTable1.getCurrentRow().qcid, XEUtils.toDateString(dateModeListRow.begindt, "yyyy-MM-dd"));
      },
      //日期模式 检索 右边明细数据
      dateModeRetrieve(qcid, begindt) {
          this.tableData52 = [];
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "tagetSetDetail",
                      qcid: qcid,
                      begindt: begindt,
                  },
              })
              .then((response) => {
                  this.tableData52 = response.Data;
                  this.tableData52.forEach((e) => {
                      //若新增，则全部勾选
                      if (e.stopdt != null && !(e.stopuser == "") && !(e.stopuser == null)) {
                          //停用不勾选
                          e.bselect = "0";
                      }
                      if (this.addFlag) {
                          e.bselect = "1";
                      }
                  });
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //输入靶值，自动计算sd\ CV
      calcCvSd({ row }, inputValue) {
          let tagvalue = inputValue.target.value;
          let sd = row.sd;
          let cv = row.cv;
          if (this.bLockCv) {
              if (Math.abs(cv) > 0) {
                  if (Math.abs(tagvalue) > 0) {
                      row.sd = parseFloat(((cv * tagvalue) / 100).toFixed(4));
                      return;
                  }
              }
          } else {
              if (Math.abs(tagvalue) > 0) {
                  if (Math.abs(sd) > 0) {
                      row.cv = parseFloat(((sd * 100) / tagvalue).toFixed(4));
                      return;
                  }
                  if (Math.abs(cv) > 0) {
                      row.sd = parseFloat(((cv * tagvalue) / 100).toFixed(4));
                      return;
                  }
              }
          }
          row.cv = null;
          row.sd = null;
      },
      //输入SD，自动计算tagvalue \CV
      calcCvTagvalue({ row }, inputValue) {
          let sd = inputValue.target.value;
          let tagvalue = row.tagvalue;
          let cv = row.cv;
          if (this.bLockCv) {
              if (Math.abs(cv) > 0) {
                  if (Math.abs(sd) > 0) {
                      row.tagvalue = parseFloat(((sd * 100) / cv).toFixed(4));
                      return;
                  }
                  // if (Math.abs(tagvalue) > 0) {
                  //     // row.tagvalue = parseFloat(((sd * 100) / cv).toFixed(4));
                  //     row.sd = parseFloat(((cv * tagvalue) / 100).toFixed(4));
                  //     return;
                  // }
              }
          } else {
              if (Math.abs(sd) > 0) {
                  if (Math.abs(tagvalue) > 0) {
                      row.cv = parseFloat(((sd * 100) / tagvalue).toFixed(4));
                      return;
                  }
                  if (Math.abs(cv) > 0) {
                      row.tagvalue = parseFloat(((sd * 100) / cv).toFixed(4));
                      return;
                  }
              }
          }

          row.cv = null;
          row.tagvalue = null;
      },
      //输入CV  自动计算 SD \Tagvalue
      calcSdTagvalue({ row }, inputValue) {
          let cv = inputValue.target.value;
          let tagvalue = row.tagvalue;
          let sd = row.sd;
          if (Math.abs(cv) > 0) {
              if (Math.abs(tagvalue) > 0) {
                  row.sd = parseFloat(((cv * tagvalue) / 100).toFixed(4));
                  return;
              }
              if (Math.abs(sd) > 0) {
                  row.tagvalue = parseFloat(((sd * 100) / cv).toFixed(4));
                  return;
              }
          }
          row.sd = null;
          row.tagvalue = null;
      },
      //项目模式， 左边列表就是 主页面右边的数据
      targetSetItemModeList() {
          this.tableData61 = this.tableData2;
          this.$refs.xTable61.setCurrentRow(null); //这个不会自动清空
          this.tableData62 = [];
          this.$refs.xTable62.setCurrentRow(null); //这个不会自动清空
          var selrow = this.$refs.xTable1.getCurrentRow();
          if (selrow) {
          } else {
              this.$message({
                  message: "请先选中要计算靶值的质控品！",
                  type: "info",
              });
              return;
          }
          this.$nextTick(() => {
              this.loadFirstRow(this.$refs.xTable61, this.itemModeListChanged);
          });
          // //list表格数据加载完成后执行
          // this.$nextTick(() => {
          //   // 加载第一行
          //   var selectrow = this.$refs.xTable61.getData(0);
          //   if (selectrow) {
          //     this.$refs.xTable61.setCurrentRow(selectrow); //高亮行
          //     this.$refs.xTable61.scrollToRow(selectrow); //滚动到行
          //     this.itemModeListChanged(selectrow); //查询  明细
          //   } else {
          //     this.$refs.xTable61.setCurrentRow(null); //这个不会自动清空
          //   }
          // });
      },

      //项目模式 list窗口行变换事件
      itemModeList_changed({ row }) {
          this.itemModeListChanged(row);
      },
      //项目模式 list行变换执行
      itemModeListChanged(row) {
          let itemModeListRow = row; //给右边Tab显示用的数据
          this.itemModeRetrieve(this.$refs.xTable1.getCurrentRow().qcid, itemModeListRow.rpt_itemcode);
      },
      itemModeRetrieve(qcid, rpt_itemcode) {
          this.$refs.xTable62.setCurrentRow(null); //这个不会自动清空
          this.tableData62 = [];
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "tagetSetDetail",
                      qcid: qcid,
                      rpt_itemcode: rpt_itemcode,
                  },
              })
              .then((response) => {
                  this.tableData62 = response.Data;
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },

      targetSetAdd() {
          this.targetSetBegindt = new Date();
          this.targetSetCopyFlag = "0"; //  默认勾选仅新增，后续可做本地记忆或记忆本次操作
          this.targetSetBegindtDialogVisible = true;
      },
      targetSetBegindtOK() {
          //targetSetCopyFlag:"0",//靶值设定:新增靶值弹窗 0:不复制，1覆盖复制，2不覆盖复制
          //日期模式下
          if (this.targetSetTabsValue == "1") {
              if (this.targetSetCopyFlag == "0") {
                  //校验 日期是否存在
                  for (let i in this.tableData51) {
                      if (XEUtils.toDateString(this.tableData51[i].begindt, "yyyy-MM-dd") == XEUtils.toDateString(this.targetSetBegindt, "yyyy-MM-dd")) {
                          //&&未勾选复制
                          this.$message({
                              message: "靶值启用日期和已有日期重复，请重新输入！",
                              type: "error",
                          });
                          return;
                      }
                  }
                  var records = {};
                  records.begindt = this.targetSetBegindt;
                  this.$refs.xTable51.insertAt(records, -1); //在最后添加一行
                  var curow = this.$refs.xTable51.getTableData().fullData[this.$refs.xTable51.getTableData().fullData.length - 1]; //获取 新加的行对象 row 数据集合
                  this.$refs.xTable51.setCurrentRow(curow); //高亮显示行
                  this.$nextTick(() => {
                      this.$refs.xTable51.scrollToRow(curow); //待数据加载完成后，延迟 滚动 到行
                      this.addFlag = true;
                      var nBegindt = XEUtils.toDateString(curow.begindt, "yyyy-MM-dd");
                      if (this.addData.indexOf(nBegindt) == -1) {
                          this.addData.push(nBegindt); //插入新增的启用日期
                      }
                      this.dateModeListChanged(curow);
                      this.targetSetBegindtDialogVisible = false;
                      this.tablekey51++;
                      this.tablekey52++;
                  });
              } else if (this.targetSetCopyFlag == "1" || this.targetSetCopyFlag == "2") {
                  this.addFlag == false;
                  var selrow = this.$refs.xTable51.getCurrentRow();
                  if (selrow) {
                  } else {
                      this.$message({
                          message: "未选择来源启动日期",
                          type: "warning",
                      });
                      return;
                  }
                  var copyBegindt = XEUtils.toDateString(selrow.begindt, "yyyy-MM-dd");
                  var newBegindt = XEUtils.toDateString(this.targetSetBegindt, "yyyy-MM-dd");
                  this.$tool
                      .request({
                          url: "LIS/LIS5/LIS511",
                          method: "post",
                          data: {
                              action: "tagetSetCopy",
                              qcid: this.qcsDisplay.qcid,
                              copyBegindt: copyBegindt,
                              newBegindt: newBegindt,
                              copyCover: this.targetSetCopyFlag ? "2" : "1",
                          },
                      })
                      .then((response) => {
                          if (response.errcode == "1") {
                              this.targetSetDateModeList(); //刷新 界面
                              this.targetSetBegindtDialogVisible = false;
                              this.$message({
                                  message: "保存成功！",
                                  type: "success",
                              });
                          } else {
                              this.$message({
                                  dangerouslyUseHTMLString: true,
                                  message: "保存失败！<br/><br/>详细信息：" + response.errmsg,
                                  type: "warning",
                              });
                          }
                      });
              }
          }
          //项目模式下
          if (this.targetSetTabsValue == "2") {
              //校验 日期是否存在
              for (let i in this.tableData62) {
                  if (XEUtils.toDateString(this.tableData62[i].begindt, "yyyy-MM-dd") == XEUtils.toDateString(this.targetSetBegindt, "yyyy-MM-dd")) {
                      this.$message({
                          message: "靶值启用日期和已有日期重复，请重新输入！",
                          type: "error",
                      });
                      return;
                  }
              }
              var records = {};
              records.begindt = this.targetSetBegindt;
              var selectrow = this.$refs.xTable61.getCurrentRow();
              if (selectrow) {
                  records.rpt_itemcode = selectrow.rpt_itemcode;
                  records.rpt_itemname = selectrow.rpt_itemname;
              }
              this.$refs.xTable62.insertAt(records, -1); //在最后添加一行
              var curow = this.$refs.xTable62.getTableData().fullData[this.$refs.xTable62.getTableData().fullData.length - 1]; //获取 新加的行对象 row 数据集合
              this.$refs.xTable62.setCurrentRow(curow); //高亮显示行
              this.targetSetBegindtDialogVisible = false;
              this.tablekey61++;
              this.tablekey62++;
              this.$nextTick(() => {
                  this.$refs.xTable62.scrollToRow(curow); //待数据加载完成后，延迟 滚动 到行
              });
          }
      },

      targetSetBegindtClose() {
          this.targetSetBegindt = "";
          this.targetSetBegindtDialogVisible = false;
      },

      // targetSetUpdate() {
      //   if (this.targetSetTabsValue == "1") {
      //     this.$message({
      //       message:
      //         "日期模式下不能修改左边的启用日期，靶值请直接在右边窗口中修改",
      //       type: "info"
      //     });
      //   }
      // },

      targetSetDelete() {
          if (this.targetSetTabsValue == "1") {
              this.$message({
                  message: "日期模式下不能删除靶值启用日期，删除靶值请直接在右边窗口中清除靶值和SD的值",
                  type: "info",
              });
          }
          if (this.targetSetTabsValue == "2") {
              this.deleteRow(this.$refs.xTable62);
          }
      },
      chkselectall_change(e) {
          if (this.tableData52 != null && this.tableData52.length > 0) {
              this.tableData52.forEach((item) => {
                  item.bselect = this.selectall == true ? "1" : "0";
              });
          }
      },
      targetSetSave_click() {
          //在事件里校验数据
          if (this.targetSetTabsValue == "1") {
              var selrow = this.$refs.xTable51.getCurrentRow();
              if (selrow) {
                  var begindt = XEUtils.toDateString(selrow.begindt, "yyyy-MM-dd");
              } else {
                  this.$message({
                      message: "请先选中左边列表中的靶值启用日期！",
                      type: "info",
                  });
              }

              var recordset = this.$refs.xTable52.getRecordset(); //定义 表格提交数据

              // recordset.updateRecords.forEach((item) => {
              //     //校验 靶值 和 SD 必须同时存在
              //     if ((item.cdata.tagvalue != null || item.cdata.sd != null) && (item.cdata.tagvalue == null || item.cdata.sd == null)) {
              //         this.$message({
              //             message: "靶值和SD必须同时输入有效数据！",
              //             type: "error",
              //         });
              //         return;
              //     }
              // });
              // var recordset = this.$refs.xTable52.getRecordset(); //定义 表格提交数据
          }
          if (this.targetSetTabsValue == "2") {
              var begindt = "";
              var selrow = this.$refs.xTable61.getCurrentRow();
              if (selrow) {
                  var rpt_itemcode = selrow.rpt_itemcode;
              } else {
                  this.$message({
                      message: "请先选中左边列表中的报告项目！",
                      type: "info",
                  });
              }
              var recordset = this.$refs.xTable62.getRecordset(); //定义 表格提交数据
              if (recordset.updateRecords.length == 0 && recordset.insertRecords.length == 0 && recordset.removeRecords.length == 0) return;
              var err = false;
              // recordset.updateRecords.forEach((item) => {
              //     //校验 靶值 和 SD 必须同时存在
              //     if (item.cdata.tagvalue == null || item.cdata.sd == null) {
              //         this.$message({
              //             message: "靶值和SD必须输入有效数据！",
              //             type: "error",
              //         });
              //         return;
              //     }
              // });
              // recordset.insertRecords.forEach((item) => {
              //     //校验 靶值 和 SD 必须同时存在
              //     if (item.tagvalue == null || item.sd == null) {
              //         this.$message({
              //             message: "靶值和SD必须输入有效数据！",
              //             type: "error",
              //         });
              //         return;
              //     }
              // });
          }
          this.$nextTick(() => {
              this.targetSetSave(begindt, rpt_itemcode, recordset, selrow);
          });
      },
      //靶值数据保存到数据库
      targetSetSave(begindt, rpt_itemcode, recordset, selrow) {
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "tagetSetSave",
                      qcid: this.qcsDisplay.qcid,
                      begindt: begindt,
                      rpt_itemcode: rpt_itemcode,
                      qcitemvalue: recordset,
                      mode: this.targetSetTabsValue,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      //刷新 界面
                      if (this.targetSetTabsValue == "1") {
                          //查询该数据是否为新增数据，是则从addData中删除
                          var key = this.addData.indexOf(XEUtils.toDateString(begindt, "yyyy-MM-dd"));
                          if (key > -1) {
                              this.addData.splice(key, 1);
                          }
                          this.addFlag = false;
                          this.dateModeListChanged(selrow);
                      }
                      if (this.targetSetTabsValue == "2") {
                          this.itemModeListChanged(selrow);
                      }

                      this.$message({
                          message: "保存成功！",
                          type: "success",
                      });
                  } else {
                      this.$message({
                          dangerouslyUseHTMLString: true,
                          message: "保存失败！<br/><br/>详细信息：" + response.errmsg,
                          type: "warning",
                      });
                  }
              });
      },
      //靶值设置 弹窗关闭
      targetSetClose() {
          this.targetSetDialogVisible = false;
      },
      //靶值复制弹窗 打开
      targetSetCopy() {
          // if (this.targetSetTabsValue == "2") {
          //     this.$message({
          //         message: "项目模式下不支持复制",
          //         type: "info",
          //     });
          // }
          //日期模式下复制到
          if (this.targetSetTabsValue == "1") {
              this.targetSetCopyDialogVisible = true;
          }
      },
      //靶值复制 弹窗确认按钮
      // targetSetCopyOK() {
      //     var selrow = this.$refs.xTable51.getCurrentRow();
      //     if (selrow) {
      //     } else {
      //         this.$message({
      //             message: "未选择来源启动日期",
      //             type: "warning",
      //         });
      //         return;
      //     }
      //     var copyBegindt = XEUtils.toDateString(selrow.begindt, "yyyy-MM-dd");
      //     var newBegindt = XEUtils.toDateString(this.targetSetCopyBegindt, "yyyy-MM-dd");
      //     this.$tool
      //         .request({
      //             url: "LIS/LIS5/LIS511",
      //             method: "post",
      //             data: {
      //                 action: "tagetSetCopy",
      //                 qcid: this.qcsDisplay.qcid,
      //                 copyBegindt: copyBegindt,
      //                 newBegindt: newBegindt,
      //                 copyCover: this.targetSetCopyCover ? "1" : "0",
      //             },
      //         })
      //         .then((response) => {
      //             if (response.errcode == "1") {
      //                 this.targetSetDateModeList(); //刷新 界面
      //                 this.targetSetCopyDialogVisible = false;
      //                 this.$message({
      //                     message: "保存成功！",
      //                     type: "success",
      //                 });
      //             } else {
      //                 this.$message({
      //                     dangerouslyUseHTMLString: true,
      //                     message: "保存失败！<br/><br/>详细信息：" + response.errmsg,
      //                     type: "warning",
      //                 });
      //             }
      //         });
      // },

      //靶值复制 关闭弹窗
      targetSetCopyClose() {
          this.targetSetCopyDialogVisible = false;
      },
      //靶值计算弹窗
      targetSetCalc() {
          this.tableData71 = [];
          this.valueitemrow = {};
          if (this.targetSetTabsValue == "1") {
              this.tableData71 = XEUtils.clone(this.tableData52, true);
          }
          if (this.targetSetTabsValue == "2") {
              var selrow = this.$refs.xTable62.getCurrentRow();
              this.valueitemrow = selrow;
              if (selrow) {
                  this.tableData71[0] = XEUtils.clone(selrow, true);
              } else {
                  this.$message({
                      message: "请选择右边窗口的行！",
                      type: "warning",
                  });
                  return;
              }
          }
          this.tableData72 = [];
          this.targetSetCalcInuse = false;
          this.targetSetCalcDraw = false;
          this.targetSetCalc3sd = false;
          this.bCalc1 = false;
          this.calcdaynum = 1;
          this.targetSetCalcDialogVisible = true;
          this.targetSetCalcDt = ["", ""];
          this.targetSetCalcDt[0] = XEUtils.toDateString(XEUtils.getWhatDay(new Date(), -20), "yyyy-MM-dd");
          this.targetSetCalcDt[1] = XEUtils.toDateString(new Date(), "yyyy-MM-dd");
          this.$nextTick(() => {
              this.loadFirstRow(this.$refs.xTable71, this.targetSetCalcRptitemChanged);
              if (this.targetSetTabsValue == "2") {
                  this.xTable71CheckAll = { checkAll: true };
              } else {
                  this.xTable71CheckAll = { checkAll: false };
              }
          });
      },
      //靶值计算弹窗，行切换事件
      targetSetCalcRptitem_changed({ row }) {
          if (row) this.targetSetCalcRptitemChanged(row);
      },
      targetSetCalcType_changed() {},
      targetSetCalcQuery() {
          let row = this.$refs.xTable71.getCurrentRow();
          if (row) this.targetSetCalcRptitemChanged(row);
      },
      //靶值计算弹窗，左边列表行切换
      targetSetCalcRptitemChanged(row) {
          let qcid = this.$refs.xTable1.getCurrentRow().qcid;
          let rpt_itemcode = row.rpt_itemcode;
          let qcdate = this.targetSetCalcDt;
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "targetSetCalcList",
                      qcid: qcid,
                      rpt_itemcode: rpt_itemcode,
                      targetSetCalcInuse: this.targetSetCalcInuse ? "0" : "1",
                      targetSetCalcDraw: this.targetSetCalcDraw ? "0" : "1",
                      targetSetCalc3sd: this.targetSetCalc3sd ? "1" : "0",
                      bCalc1: this.bCalc1 ? "1" : "0", 
                      calcdaynum: this.calcdaynum,
                      qcdate1: qcdate[0],
                      qcdate2: qcdate[1],
                  },
              })
              .then((response) => {
                  this.tableData72 = response.Data;
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      //关闭靶值计算弹窗
      targetSetCalcClose() {
          this.tableData71 = [];
          this.targetSetCalcDialogVisible = false;
      },
      //按所选项目计算靶值
      targetSetCalcOK() {
          let qcid = this.$refs.xTable1.getCurrentRow().qcid;
          let qcdate = this.targetSetCalcDt;
          var selectRecords = this.$refs.xTable71.getSelectRecords(); //定义 表格提交数据
          if (selectRecords.length == 0) {
              this.$message({
                  message: "请勾选左边列表的报告项目",
                  type: "info",
              });
              return;
          }
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "calcTarget",
                      qcid: qcid,
                      qcdate1: qcdate[0],
                      qcdate2: qcdate[1],
                      targetSetCalcInuse: this.targetSetCalcInuse ? "1" : "0",
                      targetSetCalcDraw: this.targetSetCalcDraw ? "1" : "0",
                      targetSetCalc3sd: this.targetSetCalc3sd ? "1" : "0",
                      bCalc1: this.bCalc1 ? "1" : "0",
                      calcdaynum: this.calcdaynum,
                      qcitemvalue: selectRecords,
                  },
              })
              .then((response) => {
                  var data = response.Data;
                  var selectRecords = this.$refs.xTable71.getSelectRecords();
                  for (var i = 0; i < selectRecords.length; i++) {
                      var element = selectRecords[i];
                      for (var m = 0; m < data.length; m++) {
                          var item = data[m];
                          //TODO 如遇上更小的小数位数 考虑添加选择保留几位小数。
                          if (element.rpt_itemcode == item.rpt_itemcode) {
                              if (this.targetSetCalcType == "1" || this.targetSetCalcType == "0") element.tagvalue = parseFloat(XEUtils.toFixedString(item.cp_targetvalue, 3));
                              if (this.targetSetCalcType == "2" || this.targetSetCalcType == "0") element.sd = parseFloat(XEUtils.toFixedString(item.cp_sd, 3));
                              if (this.targetSetCalcType == "3") {
                                  element.sd = parseFloat(XEUtils.toFixedString(item.cp_sd, 3));
                              }
                              if (element.tagvalue != null || Math.abs(element.tagvalue) > 0) {
                                  element.cv = parseFloat(XEUtils.toFixedString((element.sd * 100) / element.tagvalue, 3));
                              } else {
                                  element.cv = null;
                              }
                              break;
                          }
                      }
                  }
              });
      },

      //将靶值数据保存到上级页面中
      targetSetCalcSave() {
          if (this.targetSetTabsValue == "1") {
              var selectRecords = this.$refs.xTable71.getSelectRecords();
              for (var i = 0; i < selectRecords.length; i++) {
                  var element = selectRecords[i];
                  var data = this.$refs.xTable52.getTableData().fullData;
                  for (var m = 0; m < data.length; m++) {
                      var item = data[m];
                      if (element.rpt_itemcode == item.rpt_itemcode) {
                          item.tagvalue = element.tagvalue;
                          item.sd = element.sd;
                          item.cv = element.cv;
                          break;
                      }
                  }
              }
          }
          if (this.targetSetTabsValue == "2") {
              //  this.tableData71 = XEUtils.clone(this.tableData52, true);}
              var selectRecords = this.$refs.xTable71.getSelectRecords();
              for (var i = 0; i < selectRecords.length; i++) {
                  var element = selectRecords[i];
                  var data = this.$refs.xTable62.getTableData().fullData;
                  data.forEach((e) => {
                      if (e.begindt == this.valueitemrow.begindt) {
                          e.tagvalue = selectRecords[i].tagvalue;
                          e.sd = selectRecords[i].sd;
                          e.cv = selectRecords[i].cv;
                      }
                  });
              }
          }
          this.targetSetCalcClose();
      },

      // 若没有数据 ，用特定颜色表示行
      targetSetRowClassName({ row, rowIndex }) {
          if (row.qcitemvalueid == null) {
              return "";
          }
      },
      targetSetRowDateClassName({ row, rowIndex }) {
          if (row.bselect == "0") {
              return "rm-alert";
          }
      },
      //左边 若 停用，用特定颜色表示行
      rowClassName({ row, rowIndex }) {
          // if (row.stopdt > "2000-01-01") {
          if ((row.stopdt > "2000-01-01" && XEUtils.toDateString(new Date(), "yyyy-MM-dd") >= XEUtils.toDateString(row.stopdt, "yyyy-MM-dd")) || XEUtils.toDateString(new Date(), "yyyy-MM-dd") > XEUtils.toDateString(new Date(), "yyyy-MM-dd") >= XEUtils.toDateString(row.expriedt, "yyyy-MM-dd")) {
              return "rm-alert";
          }
      },
      //弹出框定性质控表格样式
      rowClassNameItem({ row, rowIndex, column }) {
          if (column.property == "controlstatus" && row.controlstatus == "0") {
              return "dangercontrol";
          }
      },

      addrptitem(code, name, row) {
          this.temprptitem.rpt_itemcode = code;
          this.temprptitem.rpt_itemname = name;
          this.dialogTestVisible = false;
      },

      ItemJudgeAdd() {
          var qcid = this.$refs.xTable3.getCurrentRow().qcid;
          var row = { seq: "", controlstatus: "", result_str: "", qcid: qcid };
          this.$refs.xTableJudge2.insertAt(row, -1).then((rows) => {
              this.$refs.xTableJudge2.setCurrentRow(rows.row);
          });
      },
      ItemJudgeDel() {
          var delrow = this.$refs.xTableJudge2.getCurrentRow();
          if (delrow) {
              this.$refs.xTableJudge2.remove(delrow);
          } else {
              this.$alert("请选择要删除的列", "提示");
          }
      },
      ItemJudgeSave() {
          // /预排序
          var fullData = XEUtils.sortBy(this.$refs.xTableJudge2.tableFullData, ["seq"]);
          let m = 0;
          for (let i = 0; i < fullData.length; i++) {
              if (fullData[i].seq) {
                  m++;
                  fullData[i].seq = m * 10;
              }
          }
          var recordset = this.$refs.xTableJudge2.getRecordset();
          var nowrow = this.$refs.xTable3.getCurrentRow();
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS511",
                  method: "post",
                  data: {
                      action: "saveItemJudge",
                      qcid: nowrow.qcid,
                      rpt_itemcode: nowrow.rpt_itemcode,
                      qc_itemjudge: fullData,
                  },
              })
              .then((res) => {
                  if (res.errcode == "1") {
                      this.$message({
                          type: "sucess",
                          message: "定性质控结果保存成功!",
                      });
                      this.QueryItemJudge(nowrow, 2);
                  } else {
                      this.$alert(res.errmsg, "错误");
                  }
              });
      },
      //自制必填校验函数，以后待扩展////////////////////////////////////////////////////////////////////////////
      valid(obj, message) {
          if (XEUtils.isUndefined(obj)) {
              return this.$message({
                  message: message,
                  type: "warning",
              });
          }
          if (XEUtils.isNull(obj)) {
              return this.$message({
                  message: message,
                  type: "warning",
              });
          }
          if (XEUtils.isString(obj)) {
              if (!XEUtils.getSize(obj) > 0) {
                  return this.$message({
                      message: message,
                      type: "warning",
                  });
              }
          }
          if (XEUtils.isDate(obj)) {
              if (obj < XEUtils.toStringDate("2000-01-01")) {
                  return this.$message({
                      message: message,
                      type: "warning",
                  });
              }
          }
      },

      //删除表格行工具//TODO 连续 点删除按钮会有失去焦点的问题待解决
      deleteRow(xTable) {
          var delrow = xTable.getCurrentRow();
          this.DelIndex = xTable.getRowIndex(delrow);
          xTable.remove(delrow);
          if (this.DelIndex > -1 && xTable.tableData.length > 0) {
              if (xTable.getTableData().fullData.length > this.DelIndex) this.DelIndex = this.DelIndex;
              else this.DelIndex = this.DelIndex - 1;
              var selectrow = xTable.getTableData().fullData[this.DelIndex];
              this.$nextTick(() => {
                  xTable.setCurrentRow(selectrow);
              });
          } else {
              var nowdata = xTable.getTableData().fullData.filter((item) => {
                  return item._XID < delrow._XID;
              });
              if (nowdata.length > 0) {
                  var selectrow = nowdata[nowdata.length - 1];
                  this.$nextTick(() => {
                      xTable.setCurrentRow(selectrow);
                  });
              }
          }
      },

      //自动加载表格的第一行，并执行回调函数
      loadFirstRow(xTable, func) {
          this.$nextTick(() => {
              // 加载第一行
              var selectrow = xTable.getData(0);
              if (selectrow) {
                  xTable.setCurrentRow(selectrow); //高亮行
                  xTable.scrollToRow(selectrow); //滚动到行
                  if (typeof func == "function") func(selectrow);
              } else {
                  xTable.setCurrentRow(null); //这个不会自动清空
              }
          });
      },

      //以下为分割条控件，指定函数
      yleftmousedown(ev) {
          let that = this;
          let el = ev.target;
          var disX = ev.clientX - el.offsetLeft;
          document.onmousemove = function (ev) {
              var l = ev.clientX - disX;
              if (l < 20) l = 20;
              that.leftwidth = l;
          };
          document.onmouseup = function () {
              document.onmousemove = null;
              document.onmouseup = null;
          };
      },
      yrightmousedown(ev) {
          let that = this;
          let el = ev.target;
          var disX = ev.clientX - el.offsetLeft;
          document.onmousemove = function (ev) {
              var l = ev.clientX - disX;
              let rw = el.parentElement.clientWidth - l;
              if (rw < 20) rw = 20;
              that.rightwidth = rw;
          };
          document.onmouseup = function () {
              document.onmousemove = null;
              document.onmouseup = null;
          };
      },
      xtopmousedown(ev) {
          let that = this;
          let el = ev.target;
          var disY = ev.clientY - el.offsetTop;
          document.onmousemove = function (ev) {
              var l = ev.clientY - disY;
              if (l < 20) l = 20;
              that.topheight = l;
          };
          document.onmouseup = function () {
              document.onmousemove = null;
              document.onmouseup = null;
          };
      },
      xbottommousedown(ev) {
          let that = this;
          let el = ev.target;
          var disY = ev.clientY - el.offsetTop;
          document.onmousemove = function (ev) {
              var l = ev.clientY - disY;
              let bh = el.parentElement.clientHeight - l;
              if (bh < 20) bh = 20;
              that.bottomheight = bh;
          };
          document.onmouseup = function () {
              document.onmousemove = null;
              document.onmouseup = null;
          };
      },
      BtnExc() {
          let index = this.$parent.$refs.itemtags.tagsList.findIndex((m) => m.name == "LIS511");
          this.$parent.$refs.itemtags.tagsList.splice(index, 1);
          this.$router.go(-1);
      },
      sortArr(arr) {
          var oarr = XEUtils.clone(arr, true);
          var narr = XEUtils.sortBy(arr);
          if (oarr == narr) return true;
          else return false;
      },
      //显示动态靶值规则
      ShowDynamicRule() {
          this.dynamictype1 = [];
          this.dynamictype2 = [];
          this.dynamiccheck2 = false;
          this.dynamiccheck1 = false;
          if (this.dynamictagvaluerule == null) this.dynamictagvaluerule = "";
          this.dynamictagvaluerule = this.dynamictagvaluerule.replace(/[^\0-9\,\-]/g, "");
          var dynamicarr = this.dynamictagvaluerule.split(",");
          var bCheck = this.sortArr(dynamicarr); //todo 匹配顺序
          var startpoint = XEUtils.toNumber(dynamicarr[0]);
          if (dynamicarr.length == 2) {
              //动态靶值的模式
              this.dynamiccheck1 = true;
              this.dynamictype1.push("计算动态靶值个数为：" + XEUtils.toNumber(dynamicarr[1]));
              if (startpoint == -1) {
                  this.dynamictype1.push("在" + XEUtils.toNumber(dynamicarr[1]) + "个点之前的点，使用该靶值启用日期的静态靶值作为判断依据。");
                  this.dynamictype1.push("第" + (XEUtils.toNumber(dynamicarr[1]) + 1) + "个点及以后的点，按照当前点前" + XEUtils.toNumber(dynamicarr[1]) + "个点计算靶值作为靶值依据。");
              } else if (startpoint > 0) {
                  this.dynamictype1.push("第1~第" + XEUtils.toNumber(dynamicarr[0]) + "个点，作为动态靶值累积，不参与判定。");
                  if (startpoint != XEUtils.toNumber(dynamicarr[1])) {
                      this.dynamictype1.push("第" + (startpoint + 1) + "~第" + dynamicarr[1] + "个点，按靶值启用时间计算靶值。");
                  }
                  this.dynamictype1.push("第" + (XEUtils.toNumber(dynamicarr[1]) + 1) + "个点及以后的点，按照当前点前" + XEUtils.toNumber(dynamicarr[1]) + "个点计算靶值作为靶值依据。");
              } else if (startpoint == 0) {
                  this.dynamictype1.push("第" + (startpoint + 1) + "~第" + dynamicarr[1] + "个点，按靶值启用时间计算靶值。");
                  this.dynamictype1.push("第" + (XEUtils.toNumber(dynamicarr[1]) + 1) + "个点及以后的点，按照当前点前" + XEUtils.toNumber(dynamicarr[1]) + "个点计算靶值作为靶值依据。");
              }
          } else if (dynamicarr.length > 2) {
              this.dynamiccheck2 = true;
              if (startpoint == -1) {
                  this.dynamictype2.push("在" + XEUtils.toNumber(dynamicarr[1]) + "个点之前的点，使用该靶值启用日期的静态靶值作为判断依据。");
              } else if (startpoint > 0) {
                  this.dynamictype2.push("第1~第" + XEUtils.toNumber(dynamicarr[0]) + "个点，作为动态靶值累积，不参与判定。");
                  if (startpoint != XEUtils.toNumber(dynamicarr[1])) {
                      this.dynamictype2.push("第" + (startpoint + 1) + "~第" + dynamicarr[1] + "个点，按靶值启用时间计算靶值。");
                  }
              } else if (startpoint == 0) {
                  this.dynamictype2.push("第" + (startpoint + 1) + "~第" + dynamicarr[1] + "个点，按靶值启用时间计算靶值。");
              }
              for (var i = 2; i < dynamicarr.length; i++) {
                  if (i == 2) {
                      this.dynamictype2.push("第" + (XEUtils.toNumber(dynamicarr[i - 1]) + 1) + "个点通过当前" + XEUtils.toNumber(dynamicarr[i - 1]) + "个点计算一次靶值。");
                  }
                  this.dynamictype2.push("第" + (XEUtils.toNumber(dynamicarr[i - 1]) + 2) + "个点~第" + XEUtils.toNumber(dynamicarr[i]) + "个点靶值不变。");
                  this.dynamictype2.push("第" + (XEUtils.toNumber(dynamicarr[i]) + 1) + "个点通过当前" + XEUtils.toNumber(dynamicarr[i]) + "个点计算一次靶值。");
              }
              this.dynamictype2.push("之后沿用第" + (XEUtils.toNumber(dynamicarr[dynamicarr.length - 1]) + 1) + "点计算的靶值。");
          }
      },
      //保存动态靶值规则
      SaveDynamicRule() {
          this.itemvaluerow.dynamictagvaluerule = this.dynamictagvaluerule;
          this.bOpenDynamic = false;
      },
      //将动态靶值规则应用到靶值启用日期的其他项目内
      SaveDynamicOther() {
          let record = this.$refs.xTable52.tableData;
          record.forEach((e) => {
              if (XEUtils.isNull(e.dynamictagvaluerule)) {
                  e.dynamictagvaluerule = this.dynamictagvaluerule;
                  e.dynamictagvalue = "1";
              }
          });
          this.bOpenDynamic = false;
      },
      OpenDynamicDlg(row) {
          if (row.dynamictagvalue == "1") {
              this.dynamictype1 = [];
              this.dynamictype2 = [];
              this.itemvaluerow = row;
              this.dynamictagvaluerule = row.dynamictagvaluerule;
              this.ShowDynamicRule();
              this.bOpenDynamic = true;
          }
      },
  },
  beforeRouteEnter(to, from, next) {
      next((vm) => {
          let that = vm;
          let altArr = [];
          document.onkeydown = function (e) {
              let key = window.event.keyCode;
              if (!that.dialogTableVisible && !that.qcCopyDialogVisible && !that.targetSetDialogVisible && !that.batchnoChangeDialogVisible) {
                  //*组合按键
                  if (altArr.length > 0) {
                      //65到90 a到z（A到Z）
                      // //*Alt + C 清除
                      // if (key == 69) {
                      //     this.BtnExc();
                      // }
                      //*Alt + E 退出
                      if (key == 69) {
                          //E 退出
                          that.BtnExc();
                      } else if (key == 77) {
                          //M 修改
                          that.masterUpdate();
                      } else if (key == 67) {
                          //C 质控品复制
                          that.qcCopy_click();
                      } else if (key == 84) {
                          //T 靶值设定
                          that.targetSet_click();
                      } else if (key == 66) {
                          //B 更换批号
                          that.batchnoChange_click();
                      }
                  } else {
                      if (key == 119) {
                          //F8 查询
                          that.initialList();
                      } else if (key == 113) {
                          //F2 新增
                          that.masterAdd();
                      } else if (key == 114) {
                          //F3 删除
                          that.masterDelete();
                      } else if (key == 18) {
                          //按下了alt
                          altArr.push(key);
                      }
                  }
              }
          };
          document.onkeyup = function (e) {
              let key = window.event.keyCode;
              if (key == 18) {
                  altArr = [];
              }
          };
      });
  },
};
</script>

<style scoped>
table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
table tr td:nth-child(even) {
  text-align: left;
}
/*
table tr td:nth-child(1) {
width: 80px;
}
*/
.showDataTable {
  font-size: 12px;
}
.showDataTable tr td {
  padding: 5px 0px 5px 0px;
}
::v-deep .dangercontrol {
  color: red !important;
}
::v-deep .el-dialog__body {
  padding: 0px 20px 10px 20px !important;
}
.dynmicmode {
  float: left;
  width: 40%;
  height: 100%;
}
.dynmichelp {
  float: right;
  margin-left: 5px;
  width: calc(60% - 5px);
  height: 100%;
  white-space: normal;
}
.dymicvalue {
  margin: 0px 10px 0px 5px;
  font-weight: 700;
  color: black;
}
.dynamictop {
  width: calc(100%-20px);
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  /* border: 1px solid #ccc; */
  position: absolute;
  z-index: 99;
}
.dynamicbody {
  padding-top: 35px;
  width: 100%;
  height: 400px;
}
.dynamicchild {
  margin-bottom: 5px;
  width: 100%;
  height: calc(50% - 2.5px);
}
.dynmictitle1 {
  padding-left: 10px;
  font-size: 14px;
  font-weight: 550;
}

.dynmictitle2 {
  padding-left: 10px;
  font-size: 13px;
  font-weight: 550;
}
.dynmictxt {
  padding-left: 10px;
  font-size: 12px;
  font-weight: 500;
}
.tabtop {
  width: 100%;
  height: 26px;
  line-height: 26px;
  background: rgb(28, 127, 240);
  color: white;
  white-space: nowrap;
}
.tab-title {
  margin: 0;
  font-size: 13px;
  /* margin: 0 1px 0 3px; */
  padding: 0 1px 0 3px;
  font-weight: 600;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
.datacenter {
  /* position: absolute; */
  height: calc(100% - 30px);
  overflow: auto;
  top: 30px;
  width: 100%;
  left: 0;
  bottom: 5px;
}
</style>
